5

Managing my Wordpress installation with Git is great. I get to deploy fixes via command line (with Capistrano), easy rollback plan, the Theme folder is a standalone project added as a submodule -- This seems like a good way to handle Wordpress' and its plugins rapid updates.

However, Source Control is not right for handling the on-growing Uploads folder under wp-content folder.

The solution, IMHO, was to create a dedicated part on my server for media, and exclude it from the project itself. This way, I can backup media in a standalone process, deploy new version without having to clone the entire 300MB folder again and again -- in short, this seems like a good solution.

Wordpress doesn't do that, though. Not out of the box.

Possible solutions:

  • Uploads files via FTP and use the image URL in posts (doubles the posting process time)

  • Use a 3rd party image hosting (Flickr, Tumblr) -- This creates a dependency I wish to avoid. I want the media on my server, under my control.

Any other ideas? How can I achieve a standalone media folder to which I can upload files from WP dashboard?

  • While this is an incredibly interesting question, I'm really not so sure that it is in scope, since, while in the context of WordPress, neither the question itself nor the answer is in any way specific to WordPress. – Chip Bennett Feb 10 '12 at 17:03
  • I think you should re-consider a 3rd party host like rackspace or amazon for images (not an image host), extremely easy to manage when set up and it solves many problems. – Wyck Feb 10 '12 at 17:14
2

Would some form of this solution work? Capistrano: Managing an uploads folder describes a way to update the symlink when deploying so you don't lose the uploads folder.

1

Just come up with this interesting question today. This is what I have tried:

1. Setup a TLD example.com and a sub domain media.example.com:

Example with Nginx:

server_name example.com;
root /var/www/example.com;

server_name media.example.com;
root /var/www/media.example.com;

Make sure both sites is available and Nginx can write to the /var/www/media.example.com directory.

2. Filter upload_dir in the example.com site:

You can use these lines of code as a plugin or put directly into themes:

add_filter('upload_dir', function($uploads)
{
  $uploads = array_merge($uploads, [
    'url'     => 'http://media.example.com',
    'path'    => '/var/www/media.example.com',
    'baseurl' => 'http://media.example.com',
    'basedir' => '/var/www/media.example.com',
  ]);

  return $uploads;
}, PHP_INT_MAX);

Now, upload a new media file to example.com site. It should work as you expected.

0

I think .gitignore will help you:

http://help.github.com/ignore-files/

  • No good. Since I deploy with Capistrano, each deploy process clones the project and switches CURRENT symlink to new release folder. If I ignore uploads, I actually lose the uploads directory. The fail here is within the basic idea of including the media inside the project, and not in a seperate media server. – konzepz Jan 20 '12 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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