[wp-trac] [WordPress Trac] #43023: Make Core Image Handling More Extensible

WordPress Trac noreply at wordpress.org
Thu Jan 4 21:35:42 UTC 2018


#43023: Make Core Image Handling More Extensible
-------------------------+-----------------------------
 Reporter:  blobfolio    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Media        |    Version:  4.9.1
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 As we are beginning to see many new and promising formats such as WebP
 (#35725), APNG, and HEIF/HEVC (#42775), it is probably time to revisit all
 of the image-related code in the Core, providing filters and hooks so that
 plugins and themes can choose to support them.

 Based on the work in #35725, it is clear there are a number of areas with
 insufficient extensibility, making it impossible for such work to be done
 by third-party code.

 [[BR]]

 '''WRAPPERS'''

 `getimagesize()`: Due to various bugs and inconsistencies within PHP,
 direct calls to this function should be replaced with a wrapper function
 capable of providing filtered responses. #35725 includes this in its
 patch.

 [[BR]]

 '''FILTERS'''

 Many functions include hard-coded datasets or conditions. By wrapping
 those in filters, third-party code can alter behavior accordingly.

  * `wp_stream_image()`
  * `wp_save_image_file()`
  * `wp_generate_attachment_metadata()` - The extensions-by-type need to be
 filterable.
  * `load_image_to_edit()` - The $mime_type switch needs a filterable
 default.
  * getid3.lib.php `ImageTypesLookup()` - Types need to be filterable.
  * class-phpmailer.php `_mime_types()` - Types need to be filterable.
  * image classes `supports_mime_type()`
  * class-wp-theme `get_screenshot()` - Filterable types.
  * `gd_edit_image_support()` - Filterable responses for both conditions.
  * `translate_smiley()` - Needs filterable types.
  * `wp_get_image_mime()`
  * `wp_attachment_is()` - Filterable extensions.
  * `wp_mime_type_icon()` - Filterable test for image files.

 [[BR]]

 '''OTHER'''

 There are additional areas that require more complicated solutions.

  * `file_is_displayable_image()` - Relies on constants which may not be
 defined, even in cases where an image type is actually supported. Haha.
  * wp-admin/includes/schema.php - $misc_exts needs to be filterable.
  * class-wp-image-editor-gd `load()` - Needs a filter around the resource
 creation. `imagecreatefromstring()` does not work consistently depending
 on the GD version installed.
  * class-wp-image-editor-gd `_save()` - Needs a filter to handle
 alternative MIME types.
  * class-wp-image-editor-gd `stream()` - Needs some means of specifying
 alternative headers and callbacks.
  * class-wp-image-editor-imagick `thumbnail_image()` - Needs some means of
 specifying options for different image types.
  * class-wp-image-editor-imagick `stream()` - Needs a shortcut filter to
 allow for completely different handling. (This is a quirk of the PHP
 extension not always properly communicating with the system binary,
 leading to segfaults, etc.)
  * class-wp-customize-media-control `to_json()` - Needs some method of
 altering the $type matching.

 [[BR]]

 '''ROADBLOCKS'''

 Additional requirements, such as defining missing PHP constants, might not
 be possible by the time plugin or theme code is executed. However by the
 time official PHP support lands, we can probably consider adding such
 values to the `compat.php` file (without necessarily providing a full
 blessing for the filetype within the Core).

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


More information about the wp-trac mailing list