WordPress.org

Ready to get started?Download WordPress

Forums

Add Media is giving long path complete with /wp-content/blogs.dir (11 posts)

  1. markp
    Member
    Posted 1 year ago #

    Since a version upgrade a while back, my multisite installation is putting the wrong (long, non-htaccess) path in the 'Link URL' field in the 'Add Media' screen.

    It used to (as it should) give a path like this to go in the post:
    http://domain.tld/files/2012/11/file.jpg
    but is giving this instead:
    http://domain.tld/wp-content/blogs.dir/33/files/2012/11/file.jpg

    This happens whether I used the single file uploader or the multi-file uploader - both being the standard WordPress items.

    The file is served fine from with either URL - so my htaccess is fine.

    It is just that I don't want the long (and wrong) URL in all of my posts.

    Cheers,
    Mark

  2. 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?

  3. markp
    Member
    Posted 1 year ago #

    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.

  4. markp
    Member
    Posted 1 year ago #

    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.

  5. markp
    Member
    Posted 1 year ago #

    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?

  6. 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?

  7. markp
    Member
    Posted 1 year ago #

    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.

  8. 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?

  9. markp
    Member
    Posted 1 year ago #

    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

  10. 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/

  11. markp
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic