WP Offload S3 1.4 Released

Today is release day for WP Offload S3 and with it comes some new features and some changes. It’s been just over two months since we released version 1.3, but as we didn’t publish a release post for that version I will include the noteworthy changes here.

Remove All Files From S3 Tool

Prior to version 1.3, removing your Media Library from S3 was a manual process and involved deleting rows from the database, which is far from ideal! This tool completely automates the process by going through your Media Library and deleting the files from S3. If a file doesn’t exist on your server, it will be downloaded before being deleted.

Remove files from S3 modal

Remove All Files From Server Tool

The ‘Remove Files From Server’ option can greatly reduce the disk usage on your server by deleting local Media Library files as they’re offloaded to S3. However, when you enable the option it doesn’t retrospectively remove the local files. That’s fine if you enable the option when first installing WP Offload S3, but what happens if you’ve already uploaded your Media Library to S3? You could potentially have thousands of files locally on your server with no easy way to remove them.

We have included a new tool to delete all Media Library files from your local server that have already been offloaded to S3. The tool is only visible when the ‘Remove Files From Server’ option is enabled. We also show a prompt when the option is enabled for the first time.

Prompt to remove server files

The files are quietly deleted in the background and the process can be paused or canceled at any time.

Sidebar tool removing server files

Better Support For Non-Latin Filenames

WP Offload S3 now fully supports filenames containing non-latin characters including Chinese. Previously, any filename starting with a non-latin character would result in an empty filename on S3. All occurrences of basename have been replaced with the i18n friendly wp_basename().

Media Library Action Permissions

Until today, anyone with the manage_options capability can access the on-demand Media Library actions, which by default is Admin users only.

Media Library S3 actions

But, what if you want to give permission to a single Editor, or a trusted Author? Up until this point, there was no easy way to grant those users permission. A new capability has been added that allows you to control which users have access to the on-demand Media Library actions. Anyone with the use_as3cf_media_actions capability will have access.

New Content Filtering Hooks

In WP Offload S3 1.2 we introduced content filtering. One of the default places that URL rewriting happens is on the_content filter which will replace any local server URLs with their S3 counterpart. If you need to filter any custom content you can simply apply the_content filter and the URLs will be rewritten as expected. However, there are quite a few additional actions that hook into the_content that you might not wish to be applied to your custom content. For example, you may not want shortcodes to be parsed or paragraph tags inserted.

In version 1.4, we are introducing 2 new hooks which allow you to filter custom content. They are: as3cf_filter_post_local_to_s3 and as3cf_filter_post_s3_to_local. These filters will automatically convert S3 URLs to local URLs and vice versa for Media Library items.

$content = 'Lorem ipsum... <img src="http://wordpress.dev/wp-content/uploads/2017/03/image.jpeg" alt="" width="300" height="200" class="alignnone size-medium wp-image-491" />';
$content = apply_filters( 'as3cf_filter_post_local_to_s3', $content );
// $content = 'Lorem ipsum... <img src="https://s3-eu-west-1.amazonaws.com/your-bucket-name/wp-content/uploads/2017/03/image.jpeg" alt="" width="300" height="200" class="alignnone size-medium wp-image-491" />';

AWS SDK Updated

The AWS SDK has been updated to version 2.8.31 and support for the London and Montreal regions has been added.

We’ve received a number of requests for supporting v3 of the SDK, which is something we will tackle in the future. The latest version of the SDK requires PHP 5.5+ and with 42.7% of all WordPress installs running on servers with PHP 5.4 or less, bumping the minimum version isn’t currently an option. The solution will be to support both SDK versions, which is going to require a substantial refactor of the WP Offload S3 codebase.

If you’re keen to have support for v3 of the SDK, please let us know. The more requests for this we get, the higher it goes on our priority list. We’re also open to having someone sponsor the development to bump the priority.

Bug Fixes

As usual, we’ve also fixed a number of bugs. Check out the full WP Offload S3 changelog for more details.

What Next?

That’s all for this update. In the next version, we plan on introducing a new tool for moving all attachments between S3 buckets. This should simplify the process of using different S3 buckets for different environments, such as production and staging. If you haven’t already, subscribe below to be the first to hear about the release. That’s all for now, let us know what you think of this release in the comments.

About the Author

Ashley Rich

Ashley is a PHP and JavaScript developer with a fondness for solving complex problems with simple, elegant solutions. He also has a love affair with WordPress and learning new technologies.

  • Craig Berry

    Super awesome. Love the removal tool addition.

  • Raymond Pirouz

    Whenever I update these plugins, I get the plugins updated message and can see that the latest version is listed, yet I continue to see that I need to update them and the indicator will not go away even if I clear cache or log out/back in. Sometimes the prompt to upgrade finally goes away after the 6th or 7th try but … really, I didn’t get around to that many today. It only happens w/your plugins so I wonder if I’ve done something wrong or if it’s got something to do with the way your plugin version is reported relative to other plugins?

    • Hi Raymond,

      Would you be able to submit a support request from the plugin so that we can dig into this issue?

  • Still no support for webp images? If this continue my license will expire first than the feature I been waiting.