When did it change?
WP 3.4.2 uses the correct URL for me on all sites. Are you sure a plugin didn’t change this?
Thread Starter
markp
(@markp)
I’m afraid I don’t exactly know when it started. I would estimate that it was early 2012 – but I wouldn’t like to guarantee it.
I think that I need to trace where this pre-defined path is coming from in the system.
Thread Starter
markp
(@markp)
OK. The function
wp_get_attachment_url
in the file
/wp-includes/post.php
is returning a value of
http://domain.tld/wp-content/blogs.dir/33/files/2012/11/file.jpg
instead of
http://domain.tld/files/2012/11/file.jpg
when I manually override (by a quick hack) the value that is passed back from this function then that is the value I see in the ‘Link URL’ field.
Doing some further debugging in that function I find that it is the value of
$uploads[‘baseurl’]
that is incorrect and that
$uploads = wp_upload_dir()
I look at this function shortly and see where it is getting it’s values.
Thread Starter
markp
(@markp)
Actually I’m not sure which line of this code
the function
wp_get_attachment_url
in the file
/wp-includes/post.php
is giving me the wrong url.
$url = $uploads[‘baseurl’] . “/$file”;
or
$url = apply_filters( ‘wp_get_attachment_url’, $url, $post->ID );
The first gives me the longhand URL, but is the second line supposed to change it to the short URL?
Unless you actually edited WP core files, I wouldn’t bother with that end of it. And if you did edit WP core files, please stop 😉
Go in to WP Admin -> Network -> Sites
Edit the site in question.
Click on Settings
Look for FileUpload URL. What’s it set to?
Thread Starter
markp
(@markp)
for ‘Fileupload Url’ I have:
http://sitedomain.networkdomain.tld/files
which is the original subdomain that, when you set up a new site, it gets set to and then I change the ‘Domain’ (with ‘Update siteurl and home as well’ checked) immediately after to ‘sitedomain.tld’, under the ‘info’ tab of the same page.
FYI
I have no value against ‘Upload Url Path’.
‘Upload Path’ is ‘wp-content/blogs.dir/33/files’.
I haven’t kept any debug edits in the core files – it is all straight up original WP.
then I change the ‘Domain’ (with ‘Update siteurl and home as well’ checked) immediately after to ‘sitedomain.tld’, under the ‘info’ tab of the same page.
WHOAH!!!
Why did you do that? Why didn’t you use a domain mapping plugin?
Thread Starter
markp
(@markp)
I can’t see how the domain is going to affect whether we have blogs.dir in the uploaded files path.
When I create a new site it always creates it in the form
sitedomain.networkdomain.tld
I can’t stop it from appending networkdomain.tld
so I immediately correct it to
sitedomain.tld
I can’t see how the domain is going to affect whether we have blogs.dir in the uploaded files path.
No, but changing the site/home URL breaks your data serialization if you don’t do it right. Which you are not. You’ve done ‘half’ of what you need to do in order to move a site on your network to a new name.
1) Change those BACK, please. And when you do, see if the images start working.
2) To domain map, use this: http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/
Thread Starter
markp
(@markp)
I don’t have a problem seeing the images on the site. The only problem I have is that the path in the ‘Link URL’ field in the ‘Add Media’ screen is the long path that includes blogs.dir. It should be the short path. See my first post.