[wp-trac] [WordPress Trac] #54476: Improve image engine detection when output format adjusted with filter.

WordPress Trac noreply at wordpress.org
Fri Nov 19 17:38:04 UTC 2021


#54476: Improve image engine detection when output format adjusted with filter.
-----------------------------+-----------------------------
 Reporter:  adamsilverstein  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Media            |    Version:  5.8
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 WordPress supports both Imagick and LibGD to generate sub sized images.
 When users upload a new image, the function `wp_get_image_editor` is
 called, which in turn passes the image to `_wp_image_editor_choose` which
 uses the file's mime type to determine which engine should be used for
 that image type.

 In some cases, users have both Imagick and LibGD installed and each engine
 supports different formats. For example, LibGD supports WebP, but Imagick
 does not. WordPress picks the correct engine to use based on the images
 mime type. This works fine, except when we attempt to adjust the default
 output format using the new `image_editor_output_format` filter introduced
 in version 5.8.

 I saw some reports on this on the modern image plugin, where the user
 could not output WebP images by default even though their system appears
 to support it.   See https://github.com/adamsilverstein/modern-images-
 wp/issues/13. In these cases, WordPress picks the wrong engine for the
 image, and the sub size generation fails.

 To fix this, we need to run the mime type through the same transformation
 we do in `get_output_format` before calling `_wp_image_editor_choose`.

 Patch incoming.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54476>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list