Rendering duplicate images when the original images have the same name but different extension

Created on 20 May 2022, about 2 years ago
Updated 28 May 2024, 27 days ago

Problem/Motivation

We found this problem on a news portal where the redactors work with a huge amount of images. It comes up in the case when the content manager wants to upload two images with the same name but with different file extensions through an image upload field allowing to upload multiple images. E.g. image.jpg and image.jpeg (or .png etc.).
In this case the final result is that after saving a node the same image appears twice, but in reality there should be two different images.

The problem is that after uploading the first image the WebP module creates the image derivative with .webp extension. Then when the second image is uploaded with the same name, the module doesn’t create a second derivative image with a different name in the background. This causes Drupal to render the same image (the first uploaded image) for both images.
Instead it would be necessary to differentiate the images somehow in the background and render the right images in the front-end.

Steps to reproduce

Take one image with the following name and extension: image.jpg
Take second different image with the following name and extension: image.jpeg
Upload the image.jpg to the system through an image field. After that upload the second image image.jpeg and save the node. Check the rendered images. The first uploaded image will be shown duplicately.

Proposed resolution

The module should handle this situation in the background by keeping the original extension and adding .webp to the end like this:
image.jpg.webp
image.jpeg.webp

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia ovenko

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024