Skip to Content
Documentation
Product Dev
Agentimage Bedrock
How to Offload Media for Vanilla WordPress

How to Offload Media for Vanilla WordPress

This guide will help you to offload media for a vanilla WordPress Site.

Prerequisites

  • A vanilla WordPress installation.
  • Requested R2 Credentials and Bucket Name from the SRE Team.
🚫
Important

Please make sure you coordinated with SRE team for Credentials and Bucket Name before proceeding.

Create a ticket to SRE team for Credentials and Set Credentials on Server Level.

  • Request the following:
    • Access Key ID
    • Secret Access Key
    • Bucket Name
    • Region (default is wnam)

Download and install the Amazon S3 and CloudFront Pro Plugin.

  • Download the Amazon S3 and CloudFront Pro plugin and upload it to your WordPress plugins directory.
  • Activate the plugin through the ‘Plugins’ menu in WordPress.
  • Activate the license key provided. (Note: License key is company property and should not be shared outside the company.)

Configure the offload media Object Prefix

  • Go to the Settings WP offload Media you will see “Add Prefix to Bucket Path”.
  • Set the prefix to Object Prefix SRE Provided.

Configuration object prefix

Download and install AIOS Offload Media Tweak R2 plugin

Start offloading media database point to cdn

🚫
Important

To offload media to a CDN, Please Send a ticket to SRE team to initiate the process of uploading media to the R2 Cloud.

Add entries to wp_as3cf_items table

Within your project directory, make a temporary file and copy snippet below (offload.sql). Do not commit this file

  • Replace <region> with s3 bucket region.
  • Replace <bucket> with s3 bucket name.
  • Replace all <project_slug> with your project slug.

Import using wp cli:

terminal
wp db import offload.sql

Check wp_as3cf_items table entries to have the correct paths.

offload.sql
INSERT IGNORE INTO wp_as3cf_items ( provider, region, bucket, path, original_path, is_private, source_type, source_id, source_path, original_source_path, extra_info, originator, is_verified ) SELECT 'aws', '<region>', '<bucket>', concat('<project_slug>/', pm.meta_value) AS path, concat('<project_slug>/', pm.meta_value) AS original_path, 0, 'media-library', p.id AS source_id, pm.meta_value AS source_path, pm.meta_value AS original_source_path, 'a:2:{s:13:"private_sizes";a:0:{}s:14:"private_prefix";s:0:"";}', 0, 1 FROM `wp_posts` p LEFT JOIN `wp_postmeta` pm ON pm.post_id = p.id AND pm.meta_key = '_wp_attached_file' WHERE p.post_type = 'attachment';
Last updated on