0

This post relates to the solution found in: Shared upload folder in wordpress multisite Using the solution from the user: TheDeadMedic

I use the filter in the above post in a Mutlisite with WooCommerce and the pictures are stored directly in: https://domain.com/wp-content/uploads/

All my subsites have their own domains like:

https://subsite1.com
https://subsite2.com
https://subsite3.com

This also implies that I can access the same picture from any domain:

https://mainsite.com/wp-content/uploads/pic.jpg 
https://subsite1.com/wp-content/uploads/pic.jpg 
https://subsite2.com/wp-content/uploads/pic.jpg 
https://subsite3.com/wp-content/uploads/pic.jpg

which is exactly what wish!

However, the problem is that when I choose the picture for a post in a sub site, the URL of the picture is still given from the main site, like;

https://mainsite.com/wp-content/uploads/pic.jpg 

which means I manually have to edit each post to get the picture with the URL to the sub site, like;

https://subsite1.com/wp-content/uploads/pic.jpg

I guess this has to do with the picture being stored with the main domain URL in the database? (wp_2_posts --> guid column shows URL as https://mainsite.com/wp-content/uploads/pic.jpg)

I wonder if it possible to add a filter so that the picture automatically gets the domain-url from the sub site in which the post or product is created, instead of from the main site?

It works as it is now, but I'd prefer not to show the users the domain of my main site when I use pictures. All domains uses Let's Encrypt SSL/TLS Certs.

Thank you very much for any help!

Bastubat

0

I guess if you are using the construct

$dirs['baseurl'] = network_site_url( '/wp-content/uploads' );

try changing this to ..

$dirs['baseurl'] = get_site_url( get_current_blog_id(), '/wp-content/uploads' );
  • Hey Justin, thanks for your answer! I'm sorry if I've been ambiguous about my problem! I believe that with this approach the pictures will indeed be put in a folder for each site, which is progress. But if I want to access them from multiple domains(sites), the URL for the picture will still be referring to the domain(site) in which they were first uploaded, not the domain in which the pictures currently displayed. – Bastubat Aug 25 '17 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.