Skip to content
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

Add the ability to prevent conversion of the original full-size JPEG file #1107

Open
adamdunnage opened this issue Apr 2, 2024 · 4 comments

Comments

@adamdunnage
Copy link

Feature Description

As requested in the WebP Uploads support forum, could we give user the option to prevent conversion of the original full-size JPEG file?

This could be done via a specific piece of code or even an option in the plugin itself to give users the ability to switch the option on/off.

@adamsilverstein
Copy link
Member

@adamdunnage Do you know what the user is trying to do? I feel like this is an edge case that is best achieved using code filters rather than adding a user control.

Looking at the code, I think the user could short-circuit the conversion for full sized images using the webp_uploads_pre_generate_additional_image_source filter, returning an error for the full sized call. That said, if the image is over the large image threshold size, core will still create the -scaled variation in WebP, that would need to be filtered out separately.

Worth noting that even though we display WebP on the front end, we always maintain the original uploaded file so images can be regenerated in any supported format.

@luciandavidescu
Copy link

Thank you for considering this.

Indeed, a way to use that filter is mainly what I'm looking for, I just couldn't figure it out yet – add_filter('webp_uploads_pre_generate_additional_image_source', '__return_false'); wouldn't work – so help would be appreciated.

For myself that would be enough. My issue is that some site owners are not comfortable displaying a file format different then the original, especially as sometimes images are in turn subject to approval by their own clients. With "thumbnails"/intermediate sizes, the conversion is accepted as they are seen as temporary and displayed in secondary locations.

Except for that, dunno, I guess there might be some other use cases – such as legacy compatibility or photography websites – that could warrant making this a checkable option.

@luciandavidescu
Copy link

Just in case anyone searches for this, it does seem to work with something like add_filter('webp_uploads_pre_generate_additional_image_source', function(){return new WP_Error();});

@adamsilverstein
Copy link
Member

That looks good @luciandavidescu - note that the image size is passed to the the filter, so if you want you could limit this to just the 'full' size (see #307 for the original introduction of the filter).

If others feel a checkbox is valuable I am not opposed to adding it, I'm glad you are unblocked in the mean time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants