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 · 11 comments · May be fixed by #1037
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Enhancement A suggestion for improvement of an existing feature

Comments

@jamesozzie
Copy link

jamesozzie commented Sep 23, 2022

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

Update: The below support topics also reference issues or queries regarding the file names that were added:

@mxbclang mxbclang added [Focus] Images [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Sep 23, 2022
@mxbclang mxbclang 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 [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only label Jul 19, 2023
@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
Copy link
Member

This issue just came up in another support topic: https://wordpress.org/support/topic/images-rename/

@reteinformatica
Copy link

reteinformatica commented Aug 26, 2024

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

Hello Paul,
I too used Performance Lab to convert images to AVIF and had the same problem with files renamed with the suffix (tilde)jpg(tilde)avif.
In the meantime they find a solution I as a temporary solution used the plugin ‘Media File Renamer’ to remove this suffix from all files in bulk. The plugin works very well.
https://wordpress.org/plugins/media-file-renamer

@jupitercow
Copy link

jupitercow commented Oct 2, 2024

I think it would be good to bring this up in this discussion. If I regenerate existing files more than once, the extension keeps building up...

When I regenerate thumbnails using that plugin, it creates a new file. I am creating webp files, and it works pretty great, but every time I do that to update existing files, it adds to the end of the filename: “-oldext.webp”, but it does it even to previously generated webp files. If you run it once, it changes filename.jpg to filename-jpg.webp. If you run it a second time, it creates a new file instead of replacing the existing, and changes the name to filename-jpg-webp.webp. A third time gets you filename-jpg-webp-webp.webp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Plugin] Performance Lab Issue relates to work in the Performance Lab Plugin only [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Status: Not Started/Backlog 📆