Support » Plugins » Hacks » Setting jpeg_quality

  • I have just editing 3 files that dictate the jpeg compression applied to an image on upload. (Images will be optimised for web before upload so no compression is needed.)

    http://adambrown.info/p/wp_hooks/hook/jpeg_quality

    But when the installation is upgraded I am sure these changes will be overwritten.

    Is there a method I can use to change the compression ratio to 100 and that will be preserved after an upgrade?

    Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • jpeg_quality is a filter hook, so yes you can just add a filter onto that hook, avoiding losing changes on upgrade..

    add_filter( 'jpeg_quality', 'jpeg_full_quality' );
    function jpeg_full_quality( $quality ) { return 100; }

    Where would you put that code? I tried the functions file but it had no effect.

    How did you test the code to confirm whether it was taking effect?

    I uploaded a photo and WordPress still compressed it. How else would you test it?

    The code only sets the compression rate, setting it to 100 doesn’t mean it won’t do any compression all together, it simply means it will compress at the highest quality, ie. 100% ..

    Does that help clarify?

    Yes. Is it not possible to do away with WordPress compression all together? I don’t understand why it is compressing the files in the first place.

    I’ve also noticed WordPress sets an upload limit but as far as I can tell gives not options to adjust or remove the limit.

    Uploading files manually is an obvious and easy solution to both of these problems, but I’m trying to set up a more simplified process for someone not so tech minded.

    I believe if you remove all the intermediate sizes WordPress should just upload the image “as is”.. because it has no intermediate sizes to make your images adhere to..

    When i refer to intermediate sizes i’m referring to the 3 different sizes shown under Settings > Media in the administration area. If you set the values for each of these sizes to 0 you’ll effectively disable the image resizing and images should then upload as is. I was actually testing these settings yesterday and i currently have 2 images in my uploads that match their original size(file size) and dimensions(width & height), so it would certainly appear to have the required effect.

    Of course that’s not going to fix any existing images, so testing should be confirmed with newly uploaded images and not those existing in the media library already.

    Are you talking about the “Thumnail Size”, “Medium Size”, and “Large Size”

    I set all those to 0 and it still compressed the image.

    Any idea?

    Setting those sizes to 0, as i mentioned before, works for me, if that doesn’t work for you i can’t imagine why(maybe you have a plugin installed that interacts with media images?).

    alanchrishughes

    (@alanchrishughes)

    No plugins.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Setting jpeg_quality’ is closed to new replies.