-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Feature Description
Based on:
- When uploading, generate both WebP and jpeg format images by default #142
- Update
the_content
with the correct image format #149
At this point, we can assume that every image would have at least 2 formats when the WebP module is enabled in this case the well-known and supported JPEG and the WebP format, (eventually leading into other formats as those are supported in WP). So this issue is mostly to define the strategy behind this image generation and decide into the approach into the transition into a modern format and still have a fallback for older browsers or users using this plugin but not necessarily interested in test/using this section of the performance plugin.
Strategy 1 - Default JPEG and WebP as an enhancement
This approach suggests keeping using JPEG in the sizes definition of the metadata of each image, creating the WebP version after all the JPEG versions were created and WebP images are created only as an enchantment for the existing images.
Benefits
- WebP would be used as an enchantment for JPEG replacing existing JPEG images with WebP versions
- Backwards compatible this approach allows for a transition into WebP formats incrementally, meaning older attachments where WebP version was not created would keep working as they are until a WebP version is created for that attachment see Regenerate existing images #24 and then WebP version would be used instead.
Problems
- Requires content modification like Update
the_content
with the correct image format #149 in order to render the new image format - New image format is not used by default and requires filtering in core functions in order to ensure a more modern image format is used appropriately.
Strategy 2 - WebP by default and JPEG as a fallback
This strategy suggests instead a logic similar to the current behavior of the plugin which is for new image uploads only create the WebP version and create the JPEG version of the images as fallback, and WebP format is used as the default image format for all new image uploads. JPEG versions for the images are created as a fallback approach.
Benefits
- Core functions like
wp_get_attachment_image_src
andthe_conent
would render automatically the modern image format, in this case WebP - Benefits from modern images out of the box due this image is already rendered by default for more core functions.
Problems
- If a user of the plugin opts out of not using WebP version a filter should be used in order to adjust the content to render the JPEG version for each image instead.
- When moving or deactivating the plugin WebP versions would remain as the main image format as the logic to render JPEG won't be available at this point.
- Requires an additional logic in place to migrate JPEG versions as the main images for each image size instead of WebP
Reasoning
The main reason to discuss this approach is to have a standard way of doing things, due if we have WebP versions for some attachments as the main images and JPEG for others things start to become more complex due we need to deal with multiple combinations, in some cases JPEG version is used an in others WebP. So knowing before approaching #149 or other places where we need to replace or update references to images we know which mime type is the main image type and which one is the one used as an enchantment.
Note in all scenarios JPEG and WebP versions would be present in the WordPress installations and no file would be removed, unless the main attachment image is removed.