[wp-trac] [WordPress Trac] #54648: Improve filter to enable setting quality for each subsize image

WordPress Trac noreply at wordpress.org
Wed Jan 19 18:15:18 UTC 2022


#54648: Improve filter to enable setting quality for each subsize image
----------------------------------------+------------------------------
 Reporter:  Mte90                       |       Owner:  adamsilverstein
     Type:  enhancement                 |      Status:  accepted
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  Media                       |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  performance
----------------------------------------+------------------------------

Comment (by Mte90):

 Talking with @codekraft seems that this filter is not executed for any
 size but just once.

 With this code seems that it isn't executed:

 {{{#!php
 <?php
 add_filter('wp_editor_set_quality', function ($quality, $mime_type, $size)
 {
     return ($mime_type == 'image/jpeg' && max($size) > 2000) ?
 round($quality * .1) : $quality;
 }, 10, 3);
 }}}

 Documentation says `Applies only during initial editor instantiation, or
 when set_quality() is run manually without the $quality argument.` I am
 not expert of this component, so it is clear if for initial means for any
 subsize or just once for the original image.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54648#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list