Automattic / Automattic/wp-calypso

Gutenberg: Uploads Files to Wrong Folder

Open
#56,901 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Feature] Post/Page Editor [Pri] Normal Bug Triaged
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
  1. Go to a site where you have older posts.
  2. Edit an old post and upload a new image as the featured image.
  3. Add an Image block and upload a new image to it.
  4. 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:

  1. Edited a post from 2019
  2. Uploaded a featured image: image's URL has 2019 on it, the post's year
  3. 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:

  1. Edited a post from 2019
  2. Uploaded a featured image: image's URL has 2019 on it, the post's year
  3. Added a Classic block, and uploaded an image through it: image's URL has 2019 on it, the post's year
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.