WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 4 years ago

#10390 new enhancement

attachments should store the WP uploads path that was configured when they were uploaded

Reported by: Denis-de-Bernardy Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.8.1
Component: Media Keywords:
Focuses: Cc:

Description

When you upload an image, currently, the uploads path (defaults to wp-content/uploads) is not stored.

If you change this later on to something else, previously inserted galleries no longer work, among multitudes of other problems.

Change History (9)

comment:1 follow-up: azaozz5 years ago

You mean change the uploads directory without moving the previously uploaded files so there are two different upload directories?

It seems the more common user case is to move the uploads directory to a new location. In that case galleries continue to work properly (as long as the sub-dirs are kept intact) but the inserted images in older posts need to be corrected.

comment:2 in reply to: ↑ 1 Denis-de-Bernardy5 years ago

Replying to azaozz:

You mean change the uploads directory without moving the previously uploaded files so there are two different upload directories?

Pretty much so, yeah. Site is currently using wp-content/uploads, and I was looking into changing that to media. So one old upload directory, and a new one. If we store the "current" uploads directory (e.g. wp-content/uploads) as a meta, we fix this.

It seems the more common user case is to move the uploads directory to a new location. In that case galleries continue to work properly (as long as the sub-dirs are kept intact) but the inserted images in older posts need to be corrected.

Right. Hence the suggestion, which would kill two birds in one stone.

comment:3 dd325 years ago

-1 to the ability to have 2 upload directories..

+1 (Like another ticket somewhere in WP) to change the url's in posts retroactively

comment:4 Denis-de-Bernardy5 years ago

I think everyone is totally agreeing on that. :-)

comment:5 follow-up: Denis-de-Bernardy5 years ago

Or rather, what needs to be done is, we store the current value of get_option(upload_dir) or whatever the useful function is, over in post_meta for that particular attachment.

That way, if the folder is changed later on, we still have the correct url -- through wp_get_attachment_url() or whatever it is, which would then use the meta instead of the generic function.

comment:6 in reply to: ↑ 5 azaozz5 years ago

Replying to dd32:

+1 (Like another ticket somewhere in WP) to change the url's in posts retroactively

To do that properly at the moment a db backup has to be made, URLs replaced, then some old posts tested to confirm success and eventually the db restored on failure. Think that's best left for a plugin or for the user to do manually as it would be needed in relatively few cases.

Replying to Denis-de-Bernardy:

Or rather, what needs to be done is, we store the current value of get_option(upload_dir) ... That way, if the folder is changed later on, we still have the correct url

But that will return the wrong URL when the folder has been moved or renamed which seem to be the most common cases.

Perhaps we need a good "canonical" plugin that can handle the different cases when moving, copying, renaming, etc. the uploads directory.

comment:7 azaozz4 years ago

  • Milestone changed from 2.9 to 3.0

No patch.

comment:8 miqrogroove4 years ago

  • Milestone changed from 3.0 to Future Release

comment:9 johnbillion4 years ago

  • Cc johnbillion@… added
Note: See TracTickets for help on using tickets.