New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce filter to use a custom mechanism to create additional mime images #307
Comments
@mitogh Issue description looks good to move forward from my perspective, just a few details:
This feels a bit odd to me. Shouldn't we use
Good point that we need to cover this usage as well. Since the functionality there is somewhat different though, my hunch is that we may be better off with a separate filter for this one. It may also require a few different parameters. But at a minimum, I think we should use a different filter name because many developers are probably not familiar with that area, and we should ensure they don't accidentally modify the edit process when they think they are only modifying the regular image generation process. Maybe we can open yet another (third) issue to explore a separate filter for the "generate additional sizes on edit" use-case? We may wanna call that something like |
The main reason for going with this approach was due we don't really have a size name, however I do agree that Core already uses
Agree that would simplify things, so let me update the original issue to only reference to the first time the image is created. |
@mitogh Thanks for the quick reply! It's a fair point that developers could also create their own size called In other words, I think it's okay here to use the term |
Thanks @felixarntz sounds good to me just wanted to make sure the original scenario was covering that but I agree that sticking to what core already does makes more sense in this case in order to be consistent. I'm updating the original issue description to note this scenario instead. |
Thanks both - just a note that @mehulkaklotar is going to pick up the Execution of this issue now it has been finalised. Along with #311 |
Fixed via #318. |
The main objective of this filter is to allow third party plugins or developers to replace the current mechanism provided by this plugin in order to introduce his own logic or mechanism to create the additional mime types.
This is a sub-issue of #160 and related to #311.
Filter
webp_uploads_pre_generate_additional_image_source
Paramaters
image
- By default anull
value, or eitherWP_Error
or an array with the details of the created image, in the same way thesave()
method is used.attachment_id
: TheID
of the attachment being processedimage_size
: The name of the image size we are looking for. When creating the additional mime type for the full image this value would befull
in the same way it occurs in WordPress core.image_details
: An array containing the properties of image size.mime_type
: The targeted mime type of the file we are looking for.Integration
This filter should be located when a new image is created in order to avoid using the performance plugin mechanism.
Suggested location for creation of images, as the first section of the function, if the filter return an array with the file and path property return that value.
Note: This filter should cover only the first time an image is created rather than including the subsequent edited versions to an image, a new filter would be created for subsequent edits to an image. For more details see: #307 (comment)
Suggested location for subsequent updates.https://github.com/WordPress/performance/blob/trunk/modules/images/webp-uploads/image-edit.php#L134When an image is updated from within the image editor, this location in order to be fired for every single image size.The text was updated successfully, but these errors were encountered: