0

While I'm not new to development, I am fairly new to WordPress. As I was reading up on how to best manage a WordPress site in source control, I found repeated advice to not check in wp-content/uploads.

I understand why from the reading. At the same time, I would still like to keep my the images that I use with the site design in some place where, should the worst happen, I can easily recover the original design.

Am I completely thinking about this the wrong way, or are there suggestions that I wasn't able to find via a search?

P.S. For a background, I am used to standalone webapps - .NET, JavaScript, Java - where images are generally committed with the code since they are fairly static and don't change often.

0

Whatever is in the wp-content/uploads directory is not source, it is data, some of it is automatically generated. Images related to source code, like images used in CSS should "live" in the theme or plugin files.

It is possible to use the likes of GIT over that directory, but the results will lack any sensible versioning information (no comments on why a file got there, not way to associate that channge with a new post being published etc) which degrade the whole thing into just a not very efficient backup system.

P.S. If you are doing any change on production which needs to go into version control, then you are doing it wrong. Changes need to be tested on development or staging servers, pushed into git and only then pulled into production (git or just FTP or maybe composer, whatever works for you).

  • Thank you for your response. I already have a dev/test/prod environment. I think your comment that my images should live in the theme caused me to realize that I should not be putting the theme images in wp-content/uploads (via the media uploader) in the first place. Thank you for pointing me in the right direction. One question - do you know if my images will stay due to a theme update (child theme for Genesis)? – JasCav May 29 '17 at 22:06
  • if you are using a chilf theme, they should stay. if you are modifying the main theme.... well for that you will need git to do merges first before updating – Mark Kaplun May 30 '17 at 2:23
0

i've got stuck in this trap a few times - you need to separate the CONTENT from the CODE in your version control, and manage backups for content in the same way you would your DATABASE, a separate and managed process for keeping incremental versions over time.

i'd suggest you write a small script which, on a regular basis, grabs a copy of the wp-uploads folder, and copies that outside of the wordpress directory, and then include that in your backup process - which could, if you wanted.

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.