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;
which means I manually have to edit each post to get the picture with the URL to the sub site, like;
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!