[wp-trac] [WordPress Trac] #10390: attachments should store the WP uploads path that was configured when they were uploaded

WordPress Trac noreply at wordpress.org
Thu May 22 18:21:29 UTC 2014


#10390: attachments should store the WP uploads path that was configured when they
were uploaded
-------------------------------+-----------------------------
 Reporter:  Denis-de-Bernardy  |       Owner:
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:  Future Release
Component:  Media              |     Version:  2.8.1
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+-----------------------------

Comment (by ericlewis):

 So the proposed solution is retroactive URL replacements of the old
 uploads directory to the new uploads directory?

 Right now, we don't store the upload dir path in the database at all
 (unless you manually set the `upload_path` option, the `UPLOADS` constant,
 or utilize the `upload_dir` filter. So we would need to set that
 somewhere, like `_upload_path`, which would need a comparison on every
 load to trigger the content migration.

 Something like

 {{{
 #!php
 <?php
 add_action( 'init', 'check_if_uploads_folder_moved' );
 function check_if_uploads_folder_moved() {
         if ( wp_upload_dir() !=  get_option( '_upload_dir' ) ) {
                 /* ... migrate post content ... */
                 update_option( '_upload_dir', wp_upload_dir() );
         }
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/10390#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list