Wordpress image size when loaded
I have a wordpress plugin that has a widget where users can upload their image. For uploading the image, I am using Wordpress's built in multimedia features including:
wp_enqueue_media();
Which gives me the same UI for loading an image from my widget as in the Media tab.
I also added my own size for the image that will be created on upload:
add_image_size( 'my_size', 360, 540, false );
And I am using this image size to display it on the interface. The problem is that when wordpress resizes the original image to this size, it is of fuzzy quality. The "my_size" image looks blurry.
Does anyone know how this can be solved. Maintain image quality when changing it, or at least not degrade quality too much.
source to share
By default, WordPress lowers image quality to reduce image size. If you don't want this to happen, you can use a filter that you adjust for the quality with which the image is saved. By default, WordPress quality was 90%, and from WordPress 4.5 it was reduced to 82%.
You can use the filter below to change the quality to 100%, this is what you need.
add_filter( 'jpeg_quality', 'image_quality');
function image_quality() {
return 100;
}
source to share