Category:Tutorials | Last modified: October 31, 2022
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:
Installing the WP Offload Media Lite plugin
From your WordPress dashboard, under the plugins tab, select “Add New”.
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.
Adding Tags is optional. Now you can click on “Next: Review” and if everything looks correct, click the “Create User” button
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.
Defining AWS Access Keys for WP Offload Media Lite
It is recommended to add the access keys through the wp-config.php file for security reasons. The code snippet is:
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.
Configure WP Offload Media Lite
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.
Once saved, WP Offload Media plugin will offload newly uploaded media to the bucket with the default settings.
WP Offload Media Lite setting
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.
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.
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.
All sites hosted at Pressable are provided the most up-to-date WordPress version for features and security, and these core files are symlinked for protection. When WordPress.org releases a new update, all sites…