1

We've been storing all of our images using the default /year/month/day, but I'm thinking there has to be a better way to store things because everytime that I update a image or pdf. I have to reupload it and it gets stored in a new location.

We occasionally get in the situation where we update a pdf that was uploaded one month, external users are linking to that one and when we reupload, it's stored in a new location instead of it being overwritten.

So to make sure that people that are linking to the correct PDF, I have to either find the original upload folder and upload through FTP or put in a redirect for the older version.

I know you can change the upload location to store in one folder, but I can see that getting out of hand.

What are best practice for storing files? I haven't been able to find a plugin that allows you to store files based on post type or choose upload location.

  • 1
    and if the pdf is cached on my isp's server, how do you think I will get access to the newer version if you keep the same url? I think your question is valid, but in practice your solution of just replacing the files has it own problems. – Mark Kaplun Jan 29 '15 at 9:20
0

If you have a lot of uploads, using the /year/month/day/ approach is recommended in order to keep the number of files in each directory manageable. (Just today I ran into an issue where there were more files in the uploads folder [~12,000] than the FTP server was configured to include in a directory listing [~10,000]. This caused quite a headache.)

If the PDF you're changing periodically is attached to a page or post, upload the new version while editing that same page or post. WP will put the uploaded image into the /year/month/day/ corresponding to the page/post it's attached to initially.

Edit: there may also be one or more plugins available that allow you to change the path of uploaded media. You could use this if the PDF isn't attached to a specific page/post to change the path/URL to match the original after uploading.

0

This may be the first time I have ever recommended a plugin as an answer, but I feel that is is very appropriate here.

Wordpress does not come with a way to replace media the way you describe.

I just tried out Enable Media Replace on a local install and it worked nicely. All you have to do is find the media you want to replace in the media library, click it, and then click the "Upload a new file" button. Then the plugin will give you further instructions.

Coding out this feature would not be a trivial task. I browsed through the plugin code and it seems to be fairly well written. It doesn't seem like it can be extended. But if you need different features, or just want to trim it down (it already seems pretty light), this would be great reference for your own plugin.

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.