WordPress.org

Make WordPress Core

Opened 5 months ago

Last modified 5 months ago

#46554 new defect (bug)

Uploaded images goes to wrong folder/date structure

Reported by: kartiks16 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.1
Component: Media Keywords: 2nd-opinion needs-patch
Focuses: Cc:

Description

Hello Team

All test are from fresh install, default theme, no settings change, no plugin…
"Organize my uploads into month- and year-based folders” option checked.

Images upload date: 17/03/2019
Single “Test Page” published date: 27/11/2018

In WordPress 4.7 – 4.7.13 – 4.8 – 4.8.9:

images uploaded from Media Library goes to …/2019/03 folder… RIGHT
images uploaded from single “Test Page” goes to …/2018/11 folder… RIGHT

In WordPress 4.9 – 4.9.10 – 5.0.4 – 5.1.1:

images uploaded from Media Library goes to …/2019/03 folder… RIGHT
images uploaded from single “Test Page” goes to …/2019/03 folder… WRONG!!!

From 4.9 version has anything changed in the way WordPress handles image uploads?
If YES, how to go back to the old way (thus images uploaded from single “Test Page” goes to “published date” folder… and not to “upload date” folder)?

Thanks!

Change History (3)

#1 @swissspidy
5 months ago

  • Keywords close added; needs-testing needs-patch removed

This was a deliberate change made in 4.9, see #10752. Citing the commit message:

When media is uploaded to a post, the upload directory is set according to the date of the post, so that the media URLs in the post match when the post was published.

A page is a slightly different beast, pages often live for years, and are regularly updated to stay relevant. This change causes media uploaded to pages to use the upload date to determine the upload directory.

I don't know if there's an easy way to change the folder structure for uploads. What's your use case for that? Why is the changed structure a problem?

#2 @kartiks16
5 months ago

  • Keywords needs-patch added; close removed

Hello @swissspidy

Thank you for replying and sharing your thoughts.

I understand in most of the cases maybe it won't impact much.

But what if someone manages a photographer’s site with thousands of photos and it is necessary to link the photos with the individual pages as a matter of order.

Do you think there is any workaround for this?

Waiting for your reply,

Thanks.

#3 @maximo71
5 months ago

Hello @swissspidy

First sorry for my english.

For my test in 4.9 to 5.1.1 version this is not true.
Also images uploaded to a previously published Post (as well as to a Media Library and to a Pages) use the upload date to determine the upload directory and not the date of the post.

Thanks.

Note: See TracTickets for help on using tickets.