#31667 closed defect (bug) (invalid)
URL from wp_get_attachment_image_src includes "sites/1" after using switch_to_blog(1)
Reported by: | leedo | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1.1 |
Component: | Upload | Keywords: | reporter-feedback |
Focuses: | multisite | Cc: |
Description
We're trying to do galleries that work across blogs in a network, and I ran into what seems like a minor bug.
Normally, our uploads directory for blog #1 is the base uploads directory. However, if we're in the admin for blog #2 and switch_to_blog(1), the uploads directory for blog #1 now has sites/1 included in it.
I was able to work around this by symlinking sites/1 to ../, but thought this might be something worth fixing.
Change History (4)
#1
follow-up:
↓ 2
@
9 years ago
- Component changed from Networks and Sites to Upload
- Keywords reporter-feedback added
Note: See
TracTickets for help on using
tickets.
In mu-plugins, I added:
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 thatis_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 ofis_main_network()
,is_main_site()
, ordefined( 'MULTISITE' )
is false. Can you confirm this on your setup?