Upload WordPress media files to Google Cloud Storage (GCS) and let it handle the image file request delivery to the users faster.
If you are having lots of images on your WordPress sites and would like to optimize image files delivery, then Google cloud storage may be helpful in many ways.
- Reduce bandwidth cost
- Serve content faster through Google low-latency network
- Reduce storage cost
The following, I will explain step-by-step how to integrate WordPress with Google cloud storage.
Create Service Account & Storage Bucket
Let’s get service account created which will be used to connect from WordPress.
- Go to Service Accounts under IAM & Admin (direct link)
- Click create service account
- Enter the service account name and select role as Storage Admin
- Select “Furnish a new private key” and select key type as JSON
- Click Create
It will download JSON key file. Keep it in a secure place. You will need this in next step while configuring the WordPress.
It’s time to create the bucket which you will use to store media files
- Login to Google cloud and go to storage >> browser (direct link)
- Click Create Bucket
- Enter the bucket name (must be unique)
- Select storage class (let it be multi-regional for better performance)
- Select multi-regional location (choose where your users are) and create
It will take few seconds, and you will see the newly created bucket on the list. Let’s make the bucket object readable by default to all the users.
- Select the bucket and click three dot icon >> edit bucket permissions
- Enter allUsers in member field and select role as storage object viewer and click Add
Edit the bucket permissions again and add newly created service account as “Storage Legacy Bucket owner.”
- Click Add
Well done! Storage bucket is ready to use. Let’s connect with WordPress.
There is a plugin called WP-Stateless (Google Cloud Media Storage) which let you integrate quickly.
Integration using WP-Stateless Plugin
Developed by Usability Dynamics, let you quickly configure. It uploads images to GCS as you upload to
It uploads images to GCS bucket whenever you uploaded to WP media library and served directly when requested.
It stores image copy on your server so in future if you don’t want to use GCS, you can just deactivate the plugin and don’t have to copy images back.
- Login to WordPress admin console and install >> activate the WP-Stateless plugin
- Go to settings >> media and you will notice configuration section for “Stateless media.”
- Select mode as CDN, enter bucket name and copy the content of downloaded JSON file into service account JSON
- Click save changes
Going forward, whenever you upload new media files, it will be uploaded to GCS bucket and will be served from there on the website.
Let’s quickly verify it.
I uploaded one png file manually through Media Library and as you can see below the URL address is from Google storage.
If you would like to upload existing images to GCS then you got to go Tools >> Stateless Sync and start the sync process.
Sync may take some time but once done; you should be able to see all images are getting loaded from Google storage.
I hope this helps you integrate WordPress with Google Cloud Storage for better image delivery to your audience.