2

How to replace "wp-content/blogs.dir" with "media" for attachment permalinks in a multisite environment?

This is how links look now:

http://url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21.jpg -or- http://subdomain.url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21.jpg

Ideally this is how the would look:

http://url.com/media/2011/06/650026_x640_21.jpg -or- http://subdomain.url.com/media/2011/06/650026_x640_21.jpg

Thank you!

5
  • can you post the code you are using to extract the initial URL?
    – Mild Fuzz
    Commented Jul 5, 2011 at 19:51
  • I'm using a [gallery] template tag.
    – MTT
    Commented Jul 5, 2011 at 19:53
  • Next Gen Gallery?
    – Mild Fuzz
    Commented Jul 5, 2011 at 19:57
  • Just the basic WP Gallery short-tag.
    – MTT
    Commented Jul 5, 2011 at 20:17
  • Do you have pretty permalinks turned on?
    – EAMann
    Commented Jul 5, 2011 at 21:31

2 Answers 2

2

Actually ... the blogs.dir part isn't used except for internally.

Let's say you have a network with two sites - http://url.com and http://sub.url.com. The files will be located in (respectively):

  • http://url.com/files/2011/06/...
  • http://sub.url.com/files/2011/06/...

The blogs.dir directory is where the images exist physically, yes, but your .htaccess file is routing the virtual directories I just listed above to the correct location.

I'm guessing you're manually putting together the URLs you reference above ... because that's not how Multisite is set up to work by default.


Update

I just tested this on my own network installation to give you a specific example.

My main blog is http://mindsharestrategy.com (custom domain mapped to a subdomain network installation - http://business.eamann.com is the same site). A recent post with images: How to Publish a WordPress Plugin - Subversion.

The first image in the post is: http://mindsharestrategy.com/files/2011/05/checkout.png

But an alternate link that also works: http://eamann.com/wp-content/blogs.dir/2/files/2011/05/checkout.png

WordPress automatically maps the /files directory for this site to /wp-content/blogs.dir/2/files via the .htaccess file.

So your image permalinks will work with the shortened version ... there's nothing you need to do there. It sounds like your problem is actually with the way the [gallery] shortcode outputs content.

3
  • Not much of an answer ;)
    – Mild Fuzz
    Commented Jul 5, 2011 at 20:19
  • That's how its working for me, I'm not making it up. :) <!-- see gallery_shortcode() in wp-includes/media.php --> <div id='gallery-1' class='gallery galleryid-476 gallery-columns-6 gallery-size-photostream'><dl class='gallery-item'><dt class='gallery-icon'><a href='http://sub.url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21.jpg' title='650026_x640_21'><img width="143" height="107" src="http://sub.url.com/wp-content/blogs.dir/21/files/2011/06/650026_x640_21-143x107.jpg" class="attachment-photostream" alt="650026_x640_21" title="650026_x640_21" /></a></dt></dl>
    – MTT
    Commented Jul 5, 2011 at 20:21
  • 1
    This is the correct answer. Your site shouldn't be using /wp-content/blogs.dir at all. That gets replaced with /files in a multisite setup.
    – Otto
    Commented Jul 5, 2011 at 21:33
0

Take a look into core:

/wp-includes/ms-default-constants.php > line 21 : UPLOADBLOGSDIR
/wp-includes/ms-default-constants.php > line 27, 28 : BLOGUPLOADDIR
/wp-admin/includes/ms.php > line 91 ; apply_filters( 'wpmu_delete_blog_upload_dir', WP_CONTENT_DIR . "/blogs.dir/{$blog_id}/files/", $blog_id );

I don't know much about WPMU/Network installs, that's such what come up from a cross file search.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.