I want to write a filter function and need help figuring out where it would be best to hook in or if there is any possibility at all.
I am utilizing the
jpeg_quality hook along with
max_srcset_image_width hook and some custom intermediate sizes for optimization purposes.
The problem is that WP only makes a copy for an image only if a registered image size is going to be lower resolution than the original.
Say that my site has registered image sizes: 600x600, 1200x1200 and I set
max_srcset_image_width to 1200 and
jpeg_quality to 60. It works great unless the user uploads an image with resolution between 600x600 and 1200x1200. Then WP will only make the 600x600 copy, and use the original image for any situation that needs larger image. Often these original images have very low compression ratios which results in double or even triple size of what they would have been if the image was processed by WP.
What I plan to do is make it so that when WP finds that a registered image size is larger then the original, then it will proceed by making a copy with the same size as the original. That way it will utilize the compression ratio that is set in
Any help appreciated.