Make WordPress Core

Opened 6 years ago

Last modified 5 months ago

#46554 assigned enhancement

Uploaded images goes to wrong folder/date structure

Reported by: kartiks16's profile kartiks16 Owned by: antpb's profile antpb
Milestone: Future Release Priority: normal
Severity: normal Version: 5.1
Component: Media Keywords: 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 (22)

#1 @swissspidy
6 years 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
6 years 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
6 years 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.

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.


2 years ago

#5 @antpb
2 years ago

  • Milestone changed from Awaiting Review to 6.2

Moving this into 6.2 for investigation. This seems fit for a filter to allow customization of the structure.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


21 months ago

#7 @antpb
21 months ago

A bit late in the 6.2 cycle to confidently deliver this change, so this should be moved to 6.3 when possible.

#8 @sabernhardt
21 months ago

  • Milestone changed from 6.2 to 6.3

This ticket was mentioned in Slack in #core-media by joedolson. View the logs.


17 months ago

#10 @antpb
17 months ago

  • Owner set to antpb
  • Status changed from new to assigned

Talking with @joedolson in the recent Media meeting he mentioned that we could add a filter to $time in _wp_handle_upload and pass the $post object as an argument. That should allow the previous behavior to be achieved.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


16 months ago

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


15 months ago

#13 @oglekler
15 months ago

  • Milestone changed from 6.3 to 6.4
  • Type changed from defect (bug) to enhancement

This ticket was discussed during the bug scrub, and it was decided to move it into 6.4 due to lack of patch, and also in the core-media meeting if was considered to be more an enhancement then a bug, so, I am changing the type as well, it should make this ticket which needs simple enough patch among the first ones to solve in the next milestone.

Props to @mukesh27

#14 @oglekler
14 months ago

  • Keywords 2nd-opinion removed

This ticket needs to add a new filter, which is described in the comment:10.

The filter needs to be properly documented as other filters in the code, and because this is pure enhancement, it should be reviewed and committed before Beta 1 (for the 6.4 it is September 26). And this filter also needs to be covered by Unit test to unsure that it will stay and work. Examples of such tests can be found with previously added filters and actions.

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


14 months ago

#16 @oglekler
13 months ago

  • Milestone changed from 6.4 to 6.5

There is no patch and no time before Beta 1 to make and test one, so, I am moving this ticket into the 6.5 milestone.

This ticket was mentioned in Slack in #core by abhanonstopnews. View the logs.


11 months ago

#18 @webcommsat
11 months ago

Update from the bug scrub November 14, 2023:

  • @rajinsharwar offered to work on a patch during the bug scrub.
  • @oglekler suggested: It looks like it shouldn't be so difficult to add a filter to allow people to change the folder themselves). But it needs proper documenting as well as a new filter and check if one parameter or more should be passed.

#19 @rajinsharwar
11 months ago

Just wanted to clarify this thing,

Single Page published date: 14/11/2008
Today Date: 14/11/2023

Images uploaded from Media Library go to …/2023/11 folder
Images uploaded from Single Page go to …/2023/11 folder

Have we now decided to change that thing, and change the Folder, when images are uploaded to the Single Page, to the folder of ".../2008/11"? cc @antpb @joedolson

#20 @swissspidy
8 months ago

  • Milestone changed from 6.5 to 6.6

This ticket was mentioned in Slack in #core by oglekler. View the logs.


5 months ago

#22 @oglekler
5 months ago

  • Milestone changed from 6.6 to Future Release

This ticket was discussed during a big scrub, this ticket need clear way forward and before this is going to the Future releases.

Add props to @hellofromTonya and @audrasjb

Note: See TracTickets for help on using tickets.