3256 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 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 ;)

1865 posts YOU TOUCH IT YOU BUY IT
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
+1 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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Interviewed on the Envato Notes blog
  • Beta Tester
  • Author had a File in an Envato Bundle
  • Author had a Free File of the Month
+4 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

1865 posts YOU TOUCH IT YOU BUY IT
  • Bought between 100 and 499 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
+1 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