Media Library Folders Pro is a WordPress plugin that enables you to organisation your images and other media into folders to make them easier to manage. Media Library Folders Pro S3 is an extension to the plugin that enables to store and mange your media files in cloud storage, using either Amazon S3 or Digital Ocean Spaces. In this article we will be working with Digital Ocean Spaces:
https://www.digitalocean.com/products/spaces/.
Digital Ocean
Start by creating a new Space, giving it a suitable name, e.g. mywebsite-images, allocate to a Project and leave' Restrict File Listing' selected.
Now create a Spaces access key. You can do this from the Spaces page using the Generate New Key button. Don't use the Generate New Token button - that's for something else, not Spaces. This will give you a Key and a Secret. Copy these as soon as they are created as you'll only see the secret once. You'll need to add both to your WordPress config file.
WordPress
Currently, due to changes to some WordPress settings, you also need to install the
jQuery Migrate Helper plugin.
wp-config
Before you can configure S3 you need to add some additional setting to the WordPress configuration file: wp-config.php, in the root of your WordPress installation, as below, replacing 'public' and 'secret' with the keys generated on Digital Ocean Spaces. The endpoint will depend on the location chosen when you created the Space, in this case Amsterdam 3.
/* MLFP Digital Ocean - mywebsite-images */
define('MF_AWS_ACCESS_KEY_ID', 'public');
define('MF_AWS_SECRET_ACCESS_KEY', 'secret');
define('MF_CLOUD_TYPE', 'do');
/* That's all, stop editing! Happy publishing. */
From the WordPress dashboard go to Media Library Folders Pro, S3 & Spaces Settings. If you haven't done so already, enter, save and activate your MLF Pro S3 licence code. You'll then find a page with a number of settings. If you already have images stored locally, the number will be displayed, with the number on S3 as 0.
It's recommended that you have a secure backup of your wp-content/uploads folder before you continue.
First, click Select Bucket & Region:
If you already have images stored locally, you can now upload these to the S3 cloud storage:
This may take a while if you have a lot of images:
You now need to update all the references to your media files so that they use the URL of the file(s) on Digital Ocean:
This may also take a while:
Note: there seems to be a problem where some files, particularly in the root folder (uploads/), do not have their file locations updated and have to be manually changed afterwards. Might be worth moving any images in the root folder to a misc folder before starting out. For other folders run Better Search/Replace on the top level folder to ensure all image locations are updated.
Now tick Use files on the cloud server and Save Changes.
You should be able to see you folder and files under Media Library Folders Pro. If there's anything wrong the filenames will be shown in red. Open the website to check that images are being displayed correctly. If all looks well, and you have a backup, go ahead and remove the files from local storage. Tick this option:
After a warning the removal process will start automatically:
Check Media Library Folder Pro and the website again. If all looks OK, we're done.
Cloud Sync
If you want to upload media files directly to your S3 bucket, or have uploaded an initial set of files to the bucket, you can use Cloud Sync to automate the creation of the media files in WordPress and MLF Pro.
Copy the following into wp-config.php below the settings you added earlier:
- define('MLFP_CLOUD_SYNC', true);
Now, deactivate and then reactivate the MLF Pro S3 plugin to make the necessary database changes. You now find a Cloud Sync option in the WordPress menu under Media Library Folders Pro.
To perform an initial synchronisation, click on Begin Sync: