Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#20840 closed enhancement (invalid)

Allow JPEG quality setting for images resized with Plupload

Reported by: dominicp's profile dominicp Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Upload Keywords:
Focuses: Cc:

Description

As far as I can tell, the quality setting for JPEGs resized with Plupload is hard-coded at 100 here: http://core.trac.wordpress.org/browser/trunk/wp-includes/js/plupload/handlers.dev.js#L104

The simplest solution I can see is to add another javascript variable for Plupload in the media.php file (http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/media.php#L1374) leveraging the already present jpeg_quality filter. Then, the line in "handler.dev.js" could just reference that variable.

Changing this:
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,

To this:
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>, resize_quality = <?php echo apply_filters( 'jpeg_quality', 100 ); ?>,

From a higher-level perspective, I have to say that I struggle a bit with the work-flow for image processing in WordPress. Like many others, I want to compress my images to speed up page loads as much as possible. The problem is that if I upload an already compressed JPEG (e.g. Quality 70), when WordPress resizes and compresses it I wind up with double compression. So, I plan to upload only upload full quality JPEGs, but when someone wants to see the full sized (original) version of the image, they get a bigger file than is necessary because I had to upload it at full quality.

I'm sorry if that doesn't make much sense, but there doesn't seem to be an easy way to have all JPEGs (even the full sized version) be compressed without double-compressing the smaller versions. From what I can gather, this used to be possible via the wp_upload_resize filter. But, in #19800, that was removed in favor of letting Plupload resize images.

Change History (5)

#1 @alexvorn2
12 years ago

maybe it would be better change the quality when resizing the image not when uploading...
by default jpeg quality is set to 90, in the image_resize function.
http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php#L467

#2 follow-up: @dominicp
12 years ago

@alexvorn2, I think you're right about that actually. I was under the impression, that the new system used Plupload to handle all of the image resizing, but it looks like it just does an initial resize, and then PHP creates all of the intermediate thumbnails.

If that's the case, you're absolutely right and we should not take my suggestion to change the quality at upload. Sorry for posting this before I fully understood the system.

I still don't see any easy way to ensure that the full sized image is also compressed after all of the intermediate images are created though. Any thoughts on that?

#3 in reply to: ↑ 2 @alexvorn2
12 years ago

Replying to dominicp:

I still don't see any easy way to ensure that the full sized image is also compressed after all of the intermediate images are created though. Any thoughts on that?

Delete resized Images.

I use a custom script that creates new images with a different url, you should too...
you can search Google for tasty theme from wpsmash, I created using the script by a guy but it's a old version...

#4 @alexvorn2
12 years ago

  • Keywords 2nd-opinion dev-feedback removed
  • Resolution set to invalid
  • Status changed from new to closed

#5 @helenyhou
12 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.