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

Allow for modification or removal of the -jpg suffix added to webp images, generated from jpg files #545

Open
jamesozzie opened this issue Sep 23, 2022 · 8 comments · May be fixed by #1037
Labels
[Focus] Images Issues related to the Images focus area Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@jamesozzie
Copy link

Feature Description

As per a user request in the forums allow for modification or removal of the naming structure of webp images that are generated from jpg files. At present when webp files are created from uploaded jpg they include a -jpg suffix.

Example: If I upload myimage.jpg the respective webp version will be titled myimage-jpg.webp

  • Support topic
  • This is the first such report in the WordPress support forums
@bethanylang bethanylang added [Focus] Images Issues related to the Images focus area [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Module] WebP Support Issues for the WebP Support module labels Sep 23, 2022
@bethanylang bethanylang added this to Backlog in [Focus] Images via automation Sep 23, 2022
@bethanylang bethanylang added the [Type] Enhancement A suggestion for improvement of an existing feature label Sep 23, 2022
@PaulSchiretz
Copy link

I second that, a filter for the suffix would be great! i used a plugin that created myimage.jpg -> myimage.jpg.webp and i'm serving those images via url rewrite. So to be able to keep serving my existing images and create new ones with the performance lab plugin it would be handy to be able to to change the suffix of the generated files!

Thx paul

@mukeshpanchal27
Copy link
Member

Thanks, Paul, for the comment.

Some background for the image extension. Plugin added the original image's extension to the WebP file name for its uniqueness in #444, for two or more images share the same file name but different mime types.

If you are aware of the rise of the same file name with different mime types issue, the filter is a good option for removing file name extensions.

Filter that adds an extension to the image name. The default value for this filter is true, so it doesn't affect the current behavior of the plugin.

/**
 * Filters whether image extensions are allowed for image names.
 *
 * By default the performance lab plugin will use the image extension for uniqueness 
 * purposes for the additional mime type image name.
 *
 * @since n.e.x.t
 *
 * @param bool $allowed_image_extension Add the image extension to the file name. Default true.
 */
$allowed_image_extension = apply_filters( 'webp_uploads_image_name_with_extention', true );

@felixarntz and @adamsilverstein, I would be interested to hear your thoughts on this?

Please review and suggest wording if I missed anything.

@adamsilverstein
Copy link
Member

I'm open to the idea of introducing some developer control here, however we may want something broader to control naming overall.

We may want to hold and revisit this once we consider adjusting the approach in the plugin to match where we wound up in core.

@kenny-nt
Copy link

How about selections between: filename.jpg to filename.jpg.webp or filename.webp
I need option: filename.jpg.webp.

@ddur
Copy link

ddur commented Jun 1, 2023

@PaulSchiretz

I second that, a filter for the suffix would be great! i used a plugin that created myimage.jpg -> myimage.jpg.webp and i'm serving those images via url rewrite. So to be able to keep serving my existing images and create new ones with the performance lab plugin it would be handy to be able to to change the suffix of the generated files!

Thx paul

@kenny-nt

How about selections between: filename.jpg to filename.jpg.webp or filename.webp I need option: filename.jpg.webp.

That would be compatible with redirection convention used on most hosting providers, even WordOps is using it by default.

Current renaming convention is pure nonsense. I guess, someone was mislead or inspired with -cropped and -rotated suffix, but that was appropriate because it is for completely different purpose.

Anyways, I wonder what else could be purpose of WebP upload module keeping jpeg thumbnails than enabling redirection for WebP enabled/disabled browsers? Same convention should be implemented for original.jpg

@ddur
Copy link

ddur commented Jun 1, 2023

@adamsilverstein

I'm open to the idea of introducing some developer control here, however we may want something broader to control naming overall.

We may want to hold and revisit this once we consider adjusting the approach in the plugin to match where we wound up in core.

Upload name is always checked for duplicate names and renamed. Thumbnails names just follow original / renamed file. That works without problems for decades. Same will work for .jpeg.webp because it will never be duplicate of original-name.jpeg. Even when .jpeg thumbnails are not generated (skipped).

@ddur
Copy link

ddur commented Jun 1, 2023

@adamsilverstein

We may want to hold and revisit this once we consider adjusting the approach in the plugin to match where we wound up in core.

This "thing" should never "wound up in core". Image Editor Class is already capable of generating both media/types (when library supports), and is already capable to regenerate images. Which is not the case with WebP - upload module that does it's "thing" only on upload. All you have to do is to handle name and use _save method twice. That would enable generating and regenerating older images for JPEG and PNG formats.

@felixarntz felixarntz added the Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only label Jul 19, 2023
@joemcgill joemcgill removed the [Module] WebP Support Issues for the WebP Support module label Apr 16, 2024
@adamsilverstein
Copy link
Member

Which is not the case with WebP - upload module that does it's "thing" only on upload.

@ddur are you sure about that? WebPs should be generated when regenerating images as well as at upload.

@westonruter westonruter added this to the webp-uploads n.e.x.t milestone May 3, 2024
@westonruter westonruter removed this from the webp-uploads n.e.x.t milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Images Issues related to the Images focus area Performance Lab Plugin Issue relates to work in the Performance Lab Plugin only [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature
Projects
10 participants