code4romania / code4romania/website-factory

Because of cache, an image uploaded with the same name appears as the previous image

Open
#433 0 comments 0 reactions 1 assignee Claimed by @overeha View on GitHub
bug :bug: Content blocks low-priority
Dominant language
PHP
Stars
26
Forks
18
Avg merge
1m
Merged PRs (30d)
14

Description

An image added to the Media Library having the same name as an older, deleted image displays the old image if the cache isn't cleared.
This is a minor bug with a low chance of reproducibility, and that doesn't reproduce if the new image is added before the old one is deleted.

The issue can be solved by changing the name of the file to something unique on upload.

## Steps to reproduce

### Expected
1. Upload an image with the name `example.png`
2. Attach the image somewhere on a published page
3. Save the page
4. The image appears on the page
5. Go back to the content block with the image
6. Remove the image
7. Click on attach
8. Remove the image from the Media Library
9. Add a visually different image but with the same name
10. The preview shows the new image
11. Attach the image in place of the last one
12. Save the page
13. The newly added image appears on the page

### Actual
1. Upload an image with the name `example.png`
2. Attach the image somewhere on a published page
3. Save the page
4. The image appears on the page
5. Go back to the content block with the image
6. Remove the image
7. Click on attach
8. Remove the image from the Media Library
9. Add a visually different image but with the same name
10. **The preview shows the old image**
11. Attach the image in place of the last one
12. Save the page
13. **The old image appears on the page**
14. Clearing the cache in admin & the page solves the issue for each

## Attachments

Screen recording reproducing the bug:

https://github.com/code4romania/website-factory/assets/2820084/c65a697f-3b81-48f7-a5f7-0bc33b57016b

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.