WordPress image resize on upload

I have wordpress plugin which has widget where users can upload their image.
For uploading image I am using wordpress built in functions for media included by:

wp_enqueue_media();

Which gives me the same UI for uploading image from my widget like it’s under Media tab.

Read More

I also added my custom size of the image to be created on upload:

add_image_size( 'my_size', 360, 540, false );

And I am using this size of the image to display it on the frontend.
The problem is that, when wordpress resize original image to this size it loose quality. The image “my_size” is like blurred.

Does anyone have some idea how this can be resolved. To keep image quality when it’s resized, or at least to not loose too much on the quality.

Related posts

1 comment

  1. By default WordPress reduces the image quality of an image to reduce its size. If you don’t want this to happen you can use a filter you customize the quality at which the image is saved. The default WordPress quality was 90%, and from WordPress 4.5 on was decreased to 82%.

    You can use the filter below to modify the quality to 100% is this is what you need.

    add_filter( 'jpeg_quality', 'image_quality');
    
    function image_quality() {
        return 100;
    }
    

Comments are closed.