Automattic / Automattic/wp-calypso
Gutenberg: Uploads Files to Wrong Folder
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.6k
- Forks
- 2k
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 552
Description
Quick summary
I'm not sure if this was reported already, but I wasn't able to find anything and I'm not really sure how to search further.
Gutenberg is uploading media files to a folder with the exact date you're uploading, not to the date from the content you're editing.
Steps to reproduce
- Go to a site where you have older posts.
- Edit an old post and upload a new image as the featured image.
- Add an Image block and upload a new image to it.
- Check both images URL, from the featured image, and the one from the Image block.
What you expected to happen
Both images should have the same URL, with the post's year.
What actually happened
The featured image's URL will have the post's year, but the image uploaded through Gutenberg won't.
I've tested with the Image and Gallery blocks, and with other file types, such as the File block uploading a PDF file, the same thing happens. Tested on both WordPress.com and WordPress.org.
Context
I first realized this issue when helping a user with something else, I tried to find an image from 2019 (with 2019 on its URL) on WP-Admin's media library, and when using the 2019 filter the image didn't show up (which might be another issue, not sure if this is actually expected - the WP-Admin media library's filter is for uploaded date, not the folder/URL). Then I noticed that an image uploaded in 2021, had the URL from a different year, which was the year from the post it was uploaded to.
Here are the steps I followed on my tests:
- Edited a post from 2019
- Uploaded a featured image: image's URL has 2019 on it, the post's year
- Uploaded an image using the Image or Gallery block: image's URL has 2021 on it, today's year
Then to compare with how it used to work, I tried using the Classic Editor and the Classic block:
- Edited a post from 2019
- Uploaded a featured image: image's URL has 2019 on it, the post's year
- Added a Classic block, and uploaded an image through it: image's URL has 2019 on it, the post's year
- The same thing happens when using the Classic Editor: image's URL has 2019 on it, the post's year
So it seems that Gutenberg isn't uploading the images to the right folder, it's uploading to the current date, instead of the content's creation date, which is how it used to be.
Not sure if this is intentional, but my guess is that users would expect this behavior to not change. If you have a page or post from 2019, you'd expect that all its files would be on the 2019 upload folder.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names the Image, Gallery, File, featured-image, and Classic block upload paths but no files or tests. Start by tracing how each path chooses the upload folder for an older post, then compare Gutenberg with the Classic Editor behavior. Done means uploads made in Gutenberg use the post's year in their URL, with regression coverage for the affected blocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript, wordpress
- Domain
- backend, frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100