3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says

In any case this is what you were asking if you really need it:

The network_site_url template tag retrieves the site url for the “main” site of the current network with the appropriate protocol, ‘https’ if is_ssl() and ‘http’ otherwise. If scheme is ‘http’ or ‘https’, is_ssl() is overridden.

http://codex.wordpress.org/Function_Reference/network_site_url

Cheers,

Parker

491 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

not sure if i got the problem but wouldn’t be simpler to just strip upload url from image and prepend upload dir to obtain file path ?

BF

3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says

not sure if i got the problem but wouldn’t be simpler to just strip upload url from image and prepend upload dir to obtain file path ? BF

Yes, is what I do in my function I guess… because when you get the image url in a sub blog, the url returned is passed through rewrite rules, so it needs to be modified to point to the real sub blog uploads folder on server, otherwise scripts like timthumb fail.

491 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

Yes, is what I do in my function I guess… because when you get the image url in a sub blog, the url returned is passed through rewrite rules, so it needs to be modified to point to the real sub blog uploads folder on server, otherwise scripts like timthumb fail.
I was suggesting to use something like
$ud = wp_upload_dir();
$file = str_replace($ud["baseurl"],$ud["basedir"],$url);
didn’t test at all but wp_upload_dir() would always provide right values whether multisite is enabled or not.

BF

3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says


Yes, is what I do in my function I guess… because when you get the image url in a sub blog, the url returned is passed through rewrite rules, so it needs to be modified to point to the real sub blog uploads folder on server, otherwise scripts like timthumb fail.
I was suggesting to use something like
$ud = wp_upload_dir();
$file = str_replace($ud["baseurl"],$ud["basedir"],$url);
didn’t test at all but wp_upload_dir() would always provide right values whether multisite is enabled or not. BF

Mmm, could work, but I never tested that… so not sure if it would work correctly… In any case I do something very similar:

$url = explode('/files/', $url);
if (isset($url[1])) {
     $url = '/blogs.dir/' . $blog_id . '/files/' . $url[1];
}

Should be tested to see what wp_upload_dir() exactly returns on a sub blog.

491 posts
  • Has referred 1000+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+8 more
pixelentity says

Should be tested to see what wp_upload_dir() exactly returns on a sub blog.
it returns sub blog correct values (blogs.dir), that i can assure.
3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says


Should be tested to see what wp_upload_dir() exactly returns on a sub blog.
it returns sub blog correct values (blogs.dir), that i can assure.

Well, in that case, that’s a perfect solution ;)

1869 posts YOU TOUCH IT YOU BUY IT
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
FRESHFACE says

The thing is that I dont want to use relative url as a ”/images/img1.jpg”, but I want to use “http://yourserver.com/wordpress/MU-blog1/img.jpg” and that’s the reason why I need to know the base url of wordpress instalation. Anyway thank you guys, I will test this solution and push it to the branch :)

3256 posts
  • Has referred 100+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+9 more
ParkerAndKent says

The thing is that I dont want to use relative url as a ”/images/img1.jpg”, but I want to use “http://yourserver.com/wordpress/MU-blog1/img.jpg” and that’s the reason why I need to know the base url of wordpress instalation. Anyway thank you guys, I will test this solution and push it to the branch :)

I guess it’s enough to add $url0 before:

$url = explode('/files/', $url);
if (isset($url[1])) {
     $url = $url[0] . '/blogs.dir/' . $blog_id . '/files/' . $url[1];
}

The whole $url is an absolute link to image ;)

Parker

1869 posts YOU TOUCH IT YOU BUY IT
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+6 more
FRESHFACE says

I just remembered why I was doing this. It’s because when you want to resize some theme images, located directly in theme folder ( shadows and other things ), it won’t work at multisite. So I have to do this small fix:

If there is a "/theme/" word in the URL, redirect to the original url :)

uploaded the 1.21 fixed version :)

by
by
by
by
by
by