• Hi,

    Having a real headache with image compression on upload to wp. I’ve tried plugins to optimize images, but this happens post upload, and the processing happens immediately on upload. I’m getting image size reductions of around 50% of the original and a very visible reduction in quality.

    I’ve also tried adding this code found from much older posts, and added to the theme funtion.php:

    add_filter(‘jpeg_quality’, function($arg){return 100;});

    but no change. Maybe I’m placing it in the wrong section(?)…

    I also understand the originals may be stored somewhere in the wp-admin but there’s no clear way to find them or load them up in the media.

    I optimize images myself before upload with jpeg images around 200kb and about 2,000 pixels wide at the largest size. Don’t think that will kill the server.

    This website is for a visual effects company and images need to look pretty sharp.

    Any help grately appreciated!

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • I added that snippet to my functions.php in my theme directory.
    And it does work there as expected.

    Alternatively you could try a plugin what does the exact same thing, e.g.:
    https://ww.wp.xz.cn/plugins/wp-resized-image-quality/

    Don’t forget that it will only work for newly uploaded images.
    For existing images you need to use a plugin that regenerates thumbnail. e.g.:
    https://ww.wp.xz.cn/plugins/regenerate-thumbnails/

    The original images are stored in the same directories as the generated smaller sizes.
    If you use the regenerate thumbnails plugin it will us the original uploaded images.

    Success,
    Kimmy

    Thread Starter adamhopper

    (@adamhopper)

    Thanks for your response.

    Yes, I always re-upload images to test. I have also tried the wp-resized-image-quality plugin, which I noticed was working for some thumbs but not for my main images when used on a page, neither did it keep the original image quality/size.

    There’s obviously some conflicting code or something preventing any of these methods from working.

    I’m using the Enfold theme if that makes any difference.

    Also I found that the original jpeg files are also compressed, so there is no master image file to regenerate from.

    It’s also not a retina issue which I beleive others have managed to solve with a retina x2 plugin.

    Using png images works as a lossless option, but these are obviously too big/slow.

    One workaround I have, which isn’t great, is to drop the original jpeg file (with a new filename) in the public_html/wp-content/uploads part of my site file browser and later alter the URL of the images in the code to point to that new image, which manages to bypass the wp compression.

    But surely there’s a better solution which enables me to use the media upload within wordpress and use high quality images on my website… ?

    Thanks

    netguru888

    (@netguru888)

    Hi,

    Is the code valid in PHP 7?

    add_filter(‘jpeg_quality’, function($arg){return 100;});

    Thanks!

    • This reply was modified 6 years ago by netguru888.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Disable Image compression’ is closed to new replies.