How to set up your WordPress to use Google Cloud Storage for your Media files
Today we are going to walk you through how to set up Google Cloud Storage for your WordPress uploads. The main reason to use this is to save disk space and use Cloud Storage as a CDN.
WordPress Google Cloud Storage Setup
For setting up WordPress to use Google Cloud storage for media library, we can use a free WP-Stateless plugin. This plugin has three modes
- Backup – Upload media files to Cloud Storage and serve local media files.
- CDN – Copy media files to Cloud Storage and serve from there.
- Stateless – Media files are not stored locally. Upload and serve media directly from Cloud Storage.
Install WP-Stateless Plugin
Login to your WordPress Dashboard and navigate to Plugins >> Add new and search for wp-stateless. You will find a plugin developed by Usability Dynamics, Inc. Click on “Install now” and activate the plugin.
Setup the Plugin with GCS
You can either click on “Begin Setup Assistant” or you can follow manual setup.
Now we will do a manual setup. Manual setup includes 3 Steps
- Create Google Cloud Storage Bucket
- Create a Service Account and download JSON files
- Complete the Wp-Stateless setup
Create Google Cloud Storage Bucket
Go to your Google Cloud console and navigate to Storage >> Browser
Click Create Bucket
Enter Bucket Name
Choose Default storage class as Multi-Regional
Select Location which is nearest to you
Click Create

Once your bucket is created click on the bucket and click the Permissions tab
Click Add members button
In the Popup add allUsers
in Members and in Roles select Storage Object Viewer
Click Add

Now your bucket is publically accessible to all users
Create a Service Account and download JSON file
To connect WordPress with Cloud Storage a service account is needed with sufficient permissions. Let’s create a service account
Go to IAM & Admin >> Service accounts
Click Create service account
In step 1
Enter Service account Name
Click Create

In step 2
Select Role Storage >> Storage Admin
Click Continue

In step 3
Click Create Key
Choose Key type as JSON
Click Create

Now a JSON key
file will be downloaded. Open the file in a text editor.
Complete the WP-Stateless setup
Go to your WordPress Dashboard and navigate to Media >> Stateless settings
In General choose Stateless
, File URL replacement to Enable
, Enter supported file types or leave default
In Bucket enter your Bucket Name
In Bucket folder leave empty
In Service account JSON paste the contents of the you downloaded while creating the Service Account in Google Cloud Platform
In Cache-Control enter public, max-age=86400
In Delete GCS File select Enable
Check out the Preview field, this is the sample of your media URLs
Click Save Changes.
Let’s test the setup quickly
Upload a file through your Media Library and check the URL of your image. It will be in the format provided by the plugin in the Preview
Additionally, if you like to upload existing images to Google Cloud Storage(GCS). Go to Tools and sync your images with GCS. This will take some time according to your image count. Once the sync is completed you can see all images served from Google Storage.