How to Embed Amazon S3 Videos into WordPress

Securing Private Media Files (like Video, Audio & PDF)

Among WordPress media security plugins that assist you in integrating your WordPress site to Amazon S3, S3MediaVault.com S3 Video and Audio Player for WordPress is probably the most popular one.

S3MediaVault offers a wide range of features to securely embed your S3 Video, Audio, PDF and other files into your WordPress Pages and Post. This includes an advanced secure video and player, security for PDF, Zips and Docs, and even uploading all of your WordPress Media files to S3 in one click. Check out their demos here.

But if you just wish to offload your public WordPress files (that you don’t need to be secure or private) to S3 (just to free up space or speed up loading), then there is a free option. So keep reading.

Amazon S3 is a low-cost web service that is used to retrieve and store unlimited data. It’s quite similar to Google Drive and considered one of the best AWS storage options.

In the article, we will tell you how to integrate Amazon S3 into your WordPress site. We will also guide you on how to deal with the code to get your videos up and running.

Before you read further.... Free Download (PDF)

Secret Side Door

Secret Google Search Tactic That Will Skyrocket Your Sales, Connect You to the Perfect Partners, Influencers & Affiliates and Send Your Google Rankings Soaring! FREE when you sign up for Digital Creators Edge, a free newsletter for Digital Creators who wish to take their business to the next level.

So, let’s get started.

Major Tiers of Amazon S3

Amazon S3 has several storage tiers to accommodate different kinds of potential use cases.

  • Standard storage tier is intended for those use cases where quick access is expected and high availability is needed.
  • Standard infrequent tier is handy where high-level availability is needed, though speedy access is not essential, like private user-submitted data or backups for dormant accounts.
  • Glacier storage is useful to archive data for those cases where access latency of minutes – hours is acceptable.

To integrate your site with Amazon S3, you’ll need to have an Amazon Web Services account, a public Amazon S3 bucket, and any top-rated WordPress plugin.

How to Use WordPress with Amazon S3 for Public Files

WP Offload Media Lite Plugin allows you to copy videos, images, and any other type of media files to Amazon S3. Amazon S3 web service regularly checks data consistency by analyzing and checking control hash sums. If any sort of data corruption is detected, then the object in Amazon S3 is detected and recovered by using the redundant data.

Below is a step-by-step guide that you should follow so that you can start using your Amazon S3 with your WordPress website. Before you get started, remember to back up the precious data of your site.

Step 1: Install WP Offload Media Lite Plugin

First, you need to install the WP Offload Media Lite plugin on your WordPress site. After installing and activating this plugin, you need to define the AWS keys. Now the question is how you can generate the AWS keys, let’s find the answer in the next few steps.

Step 2: Create an S3 Bucket

An S3 bucket consists of files that are publicly available on the internet, so you should be absolutely sure that your account-wide S3 permissions allow public bucket access. To create an S3 bucket, go to the S3 console and then click on “Block public access.”

Next, you should see if all public access is checked or not, and click on the edit button. Then, clear the checkbox next to “Block all public access.”

For the application, you will have to allow access via ACL. Do make sure that the first two boxes are cleared & the last two boxes are checked, then save changes.

pda-block-public access

Now that all the public access permissions are set, it’s time to create the bucket. For that, you need to click buckets on the left-hand menu and then click on “Create Bucket.”

It’s time to give your bucket a name. Keep in mind that all S3 bucket names should be globally unique. Write the name of the created bucket in your notepad, you will enter this name in your WordPress configuration later.


Then select the actual origin of the bucket and uncheck “Block all public access.” Check the last two sub boxes. This is actually the same as what you have performed in the previous section. But this time you‘re setting the policy for this specific bucket instead of the whole account.


Check the box so that you can make this bucket public and then click on “Create bucket.”

Congratulations! You can now store your media files in the newly created bucket.


Step 3: Create an IAM User

In this section, we will create an IAM user with the right set of permissions to copy the media files from WordPress to your S3 bucket. So for storing media files on Amazon S3, WordPress CMS has to provide credentials that prove it has the appropriate permissions.

First, you have to create an IAM policy. And then you need to add a new IAM user & assign the policy you have created. Once the right credentials are created, you need to add them to your WordPress configuration file. Let’s create the IAM policy first.

  1. Go to the IAM home page.
  2. Select policies from the left-hand menu.
  3. Click on the JSON tab.

The next step is to create a new user, and then apply the IAM policy you have just created.

  1. Click on “Users” from the left-side menu.
  2. Tap on the “Add user” button to give your user a meaningful name.
  3. Check the “Programmatic access” box and then click Next > Permissions.
  4. Tap on “Attach existing policy” and write your user name in the search bar.
  5. Click Next > Tags at the bottom of your screen.
  6. Tap on “Create User.”

Step 4: Add Access Keys to the wp-config.php File

Congrats! You almost complete the AWS interface.

Now it’s time to edit the wp-config.php file. There are two ways to edit this file. You can edit it with FTP or using the cPanel file manager. Simply include the given code in your wp-config.php file.

define ( 'AS3CF_AWS_ACCESS_KEY_ID', '********************);
define ( 'AS3CF_AWS_SECRET_ACCESS_KEY', '********************);

Step 5: Configure the WP Official Media Lite Settings

Next, you need to go to Settings > Offload S3, type in your S3 bucket’s name, and simply click on “Save Bucket.” So, any new media files you upload at this point in time will automatically be offloaded to the Amazon S3.


This plugin will help you automatically rewrite the media file URLs so that they’re served from Amazon S3 instead of your web server. You can simply test this plugin by uploading a new file.

Step 6: Connect Amazon S3 with a CDN

You can also use a CDN in combination with the Amazon S3. You can easily connect to Amazon CloudFront from your AWS account. All you need to do is to enter your Amazon S3 bucket link while creating a CDN.

To check your S3 bucket URL, you just need to follow this simple format: https://bucket_name.s3.amazonaws.com/

There’s also a possibility to use Cloudflare with the Amazon S3. Once your CDN is set up, you can simply use WP Offload Media Lite’s CloudFront plugin or custom domain option for rewriting your file links to use any CDN instead of the S3 bucket.


That’s it!

Embed Amazon S3 Videos into WordPress

Embed Amazon S3 Public Videos

Following the above steps, you have successfully synced or offloaded your videos from the WordPress site to Amazon S3 public bucket.

Now all you need to do is to replace the original link with the sample link created by S3 in the post edit section.

Accordingly, visitors can view the videos on your WordPress site.

How to Embed Amazon S3 Videos into WordPress while Protecting Them?

We’ve guided you in detail on how to connect your WordPress site with Amazon S3 to automatically sync your videos to the S3 public bucket. And then, you can easily replace your video’s original link with the Amazon S3 link.

In another situation, the question arises when you want to keep your videos accessible to specific users only. The normal method cannot help you achieve this. It’s when the Prevent Direct Access Gold plugin and Protect WordPress Videos extension come in handy.

Step 1: Create a Private S3 Bucket

You’ll need to follow the same steps to create a public bucket in the How to Connect WordPress with Amazon S3 in the Public section. The only difference lies in step 2 where you should leave the setting as default under Configuration options and Set permissions to create a private bucket.

After you create users, it will show you the security credentials for the user including AWS Key and AWS Secret. Amazon will not display this information again, so remember to download the .csv file and keep it somewhere safe.

Before moving to the next step, please make sure that you have Prevent Direct Access Gold plugin and Protect WordPress Videos extension installed and activated on your site.

Step 2: Amazon S3 configuration

Go back to PDA Protect WordPress Videos extension’s settings and input the information you get above under the “Amazon S3 Configuration” section.



Step 3: Embed the S3 shortcode into content

Once you’re done with the AWS configuration, all you need to do is copy the shortcode containing the S3 link of your private video/audio to content.

  • Go to your bucket and click on the video’s name to get its S3 link. It would look like this: https://s3-ap-southeast-1.amazonaws.com/my-bucket/my-private-video.mp4
  • Add the file URL to the shortcode as follows:

Default player




  • Copy and paste the shortcode into your content. Finally, save and check out the result.

Limitation: At the moment, our plugin doesn’t support cover photos or autoplay videos when using the S3 shortcode.

Now the embedded videos will display in your post and page. In addition, you can decide how to restrict access to videos and avoid users from downloading them in the Prevent Direct Access Gold plugin’s settings.

Final Thoughts

If you wish to securely embed your S3 Videos, Audio and PDF files into your WordPress website, check out S3MediaVault.com. If you wish to secure your WordPress files, check out PreventDirectAccess.com.

And if you wish to simply offload all of your public media files to S3, then the above article explained how to do just that using a free plugin.

In case you want to restrict access to embedded videos, you should consider getting our Prevent Direct Access Gold Plugin and Protect WordPress Videos extensions. They would help you to control the visibility of your videos and even prevent them from being downloaded.

Have you got any solutions on this topic? Leave a comment below to discuss more!