How to Offload WordPress Media to AWS S3

Why you should offload media to an external service:

Media files (image, video and audio files) are often quite large in size and can quickly use up your storage quota. Additionally, if your site is heavily using this type of media, it could become difficult to manage your available disk storage space optimally. The solution in such situations is to offload media storage to an external service like an AWS S3 bucket using a plugin such as WP Offload Media Lite. This plugin automatically copies all media i.e. images, videos, documents, and any other media added to your site through the WordPress media uploader to Amazon S3.

Please note: the free version of the plugin will only offload new media uploaded to WordPress. If you wish to offload existing media from your library, you will need to use the paid version of the plugin.

Steps to offload WordPress media to AWS S3:

  • From your WordPress dashboard, under the plugins tab, select “Add New”.
  • Search for “WP Offload Media Lite” and click on “Install Now”

WP Offload Plugin by Delicious Brains.

Here is an in depth documentation from the plugin developers, Delicious Brains on this: https://deliciousbrains.com/wp-offload-media/doc/amazon-s3-quick-start-guide/

The steps are described here as well:

  1. Login to your Amazon Web Services (AWS) account. If you are a new user, you will need to sign up.
  2. Once you have logged into the console, you will need to create a new IAM user by going here: https://console.aws.amazon.com/iam/home#/users. Please note that the Access type is selected to be Programmatic access.AWS Account Setup process.
  3. Next, under the Permissions page, you need to grant specific permissions to allow the new user to manage buckets and objects in the S3 service.Click the “Attach existing policies directly” button, and then enter “s3” in the filter policies input box. Now select the “AmazonS3FullAccess” policy.This is the recommended policy by the plugin developers to avoid any potential problems when first setting up. You can always update this with a custom IAM policy later.Creating a new IAM user.
  4. Adding Tags is optional. Now you can click on “Next: Review” and if everything looks correct, click the “Create User” button
    Selecting an AWS access type.Review the AWS user settings to make sure they're correct.
  5. After the user is successfully created, you will see a screen with the Access Key ID and the Secret Access Key. You will need to download these as .csv and save them somewhere safe. You can now close this.
    You have successfully added a new user.

It is recommended to add the access keys through the wp-config.php file for security reasons. The code snippet is:

define( 'AS3CF_SETTINGS', serialize( array(
     'provider' => 'aws',
        'access-key-id' => '********************',
        'secret-access-key' => '******************',
) ) );

This can be found in the plugin settings on your WordPress dashboard. These should be placed before /* That’s all, stop editing! Happy publishing. */ in the wp-config.php file.

Amazon S3 storage provider access key.

Viewing and editing the wp-config.php file.

To start offloading newly uploaded WordPress media to AWS S3, an Amazon S3 bucket needs to be created.
You will have to first sign up with Amazon S3 if you haven’t so already.

If you have already created an S3 bucket, you can just add the bucket name in the “Media Library” tab. Alternatively you can select “Create new bucket” and follow the instructions to set up a new S3 bucket.

How to Offload WordPress Media to AWS S3

Once saved, WP Offload Media plugin will offload newly uploaded media to the bucket with the default settings.

The default settings are seen here. The few settings that we suggest you change are:

  • Force HTTPS ON as all the sites hosted by Pressable are HTTPS encrypted.
  • Remove Files From Server ON – this would help with better managing your disk space usage on Pressable.
    Adjusting the WP Offload Media Lite settings.

Offloading your existing Media Library is also probably something that you’d want to do. This feature is only offered with the paid plans of the plugin. In the right-hand sidebar of the “Media Library” tab, clicking the button “Offload Now”, this will offload existing media to the bucket.

Your media library needs to be offloaded.

That’s all there is to it, your WordPress site is now all set up to offload media to Amazon S3!

Note: WP Offload Media Lite works best with a cron job setup
One thing to note is that WP Offload Media Lite relies on background processes and having a proper cron job configured is recommended. Here’s a guide on How to manage cron jobs at Pressable.