Media Library Folders Pro S3

Media Library Folders Pro S3

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.

If you are starting from a blank website and want to upload a set of existing images, this can be made a lot easier using FileZilla Pro, which includes support for S3: https://www.digitalocean.com/community/tutorials/how-to-use-filezilla-pro-with-digitalocean-spaces.

WordPress

You'll need the Media Library Folders Pro and Media Library Folders Pro S3 plugins installed, and to add a valid licence key for each.
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.
  1. /* MLFP Digital Ocean - mywebsite-images */
    define('MF_AWS_ACCESS_KEY_ID', 'public');
    define('MF_AWS_SECRET_ACCESS_KEY', 'secret');
    define('SPACES_ENDPOINT','https://ams3.digitaloceanspaces.com/);
    define('MF_CLOUD_TYPE', 'do');

    /* That's all, stop editing! Happy publishing. */

Media Library Folders Pro S3 Settings

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:
  1. 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:











    • Related Articles

    • Media Library Folders

      If you are working with many images it is easier to manage them if they are stored in folders. While this isn't a  standard option in WordPress there are plugins that add this facility, On of which is Media Library Folders, available as a free plugin ...
    • Media Library

      The Media Library contains all the images and other documents used on the website. From the WordPress menu you add either view existing files using Library: or add new files using Add New: Whenever you need to add media such as images to a post, ...
    • Download Attachments

      Download Attachments is a plugin that allows you to easily add and display download links in any post or page. You upload attachment files to the Media Library directly from the page and then add either a simple Downloads panel containing all ...
    • Create a Product

      This is a guide to creating a product using WordPress & WooCommerce, taking you through the key main tasks. The process may vary depending on the nature of the product. Before starting, prepare a suitable  set of images for the product. If the ...
    • WordPress Menu

      The WordPress menu has some standard options plus any that have been added by plugins. These are the most commonly used ones: Use the Updates option to update WordPress, plugins and your theme. Posts are the type of page you'd use for blogs posts, ...