[wp-trac] [WordPress Trac] #31667: URL from wp_get_attachment_image_src includes "sites/1" after using switch_to_blog(1)

WordPress Trac noreply at wordpress.org
Wed Apr 8 03:39:53 UTC 2015


#31667: URL from wp_get_attachment_image_src includes "sites/1" after using
switch_to_blog(1)
-------------------------------+------------------------------
 Reporter:  leedo              |       Owner:
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Upload             |     Version:  4.1.1
 Severity:  normal             |  Resolution:
 Keywords:  reporter-feedback  |     Focuses:  multisite
-------------------------------+------------------------------
Changes (by jeremyfelt):

 * keywords:   => reporter-feedback
 * component:  Networks and Sites => Upload


Comment:

 In mu-plugins, I added:

 {{{
 add_action( 'admin_init', 'jf_do_this' );
 function jf_do_this() {
         switch_to_blog(1);
         die( wp_upload_dir()['path'] );
 }
 }}}

 At first, my uploads directory was as expected, `/srv/www/wordpress-
 develop/src/wp-content/uploads/2015/04`.

 If I set `BLOG_ID_CURRENT_SITE` to 2 so that `is_main_site()` returns
 false on blog_id 1, then I get an uploads directory of `/srv/www
 /wordpress-develop/src/wp-content/uploads/sites/1/2015/04`.

 Looking at `wp_upload_dir()`, the only way to trigger this should be if
 one of ` is_main_network()`, `is_main_site()`, or `defined( 'MULTISITE' )`
 is false. Can you confirm this on your setup?

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


More information about the wp-trac mailing list