WP GCS Media
This is a wordpress plugin in php. It is used to store/sync wordpress media files from gcs cloud storage bucket
by Aravind · github.com/aravindbalasundaram/wp-gcs-media-plugin
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/aravindbalasundaram/wp-gcs-media-plugin/archive/refs/heads/main.zipA WordPress plugin written in PHP to store, sync, and serve media files (images, videos, documents, etc.) from a Google Cloud Storage (GCS) bucket instead of the local WordPress uploads directory.
This helps reduce server storage usage, improve media delivery performance, and centralize file storage on Google Cloud.
🚀 Features
- Automatically uploads WordPress media files to Google Cloud Storage.
- Syncs existing WordPress media library with GCS.
- Serves media directly from GCS public URLs or via a custom CDN domain.
- Supports all WordPress media types (images, videos, PDFs, etc.).
- Works seamlessly with the WordPress Media Library.
- Simple admin settings page for configuration.
📦 Installation
1. Manual Upload
-
Download or clone this repository:
git clone https://github.com/aravindbalasundaram/wp-gcs-media-plugin.git
-
Copy the folder wp-gcs-media-plugin into your WordPress wp-content/plugins/ directory.
-
Activate the plugin from WordPress Admin → Plugins.
2. Zip Install (Optional)
- Zip the folder:
cd wp-gcs-media-plugin zip -r wp-gcs-media-plugin.zip .
-
Go to WordPress Admin → Plugins → Add New → Upload Plugin.
-
Upload the wp-gcs-media-plugin.zip file and activate.
====
⚙️ Configuration
- Create a Google Cloud Storage (GCS) Bucket
- Go to the Google Cloud Console
- Create a new bucket (or use an existing one).
- Make sure the bucket has the correct permissions for read/write access.
- Create a Service Account & Key
- In Google Cloud Console, go to IAM & Admin → Service Accounts.
- Create a new service account with the role:
- Storage Object Admin
- Storage Object Viewer
- Generate a JSON key file and download it.
- Place this file inside your WordPress server, e.g.: /var/www/html/wp-content/gcs-key.json
- Configure Plugin Settings
In your wp-config.php, define the following:
define('GCS_BUCKET', 'your-gcs-bucket-name'); define('GCS_KEY_FILE', DIR . '/gcs-key.json'); // Service Account JSON define('GCS_PROXY_DOMAIN', 'https://your-proxy-domain.com'); // Change to your proxy domain
If you don’t provide CGM_PROXY_DOMAIN, files will be served from the default GCS bucket URL.
📂 How It Works
-
When you upload a file via WordPress Media Library:
- The file is uploaded to GCS.
- The local file can optionally be deleted (to save server space).
- The WordPress attachment URL points to the GCS public URL.
-
When accessing the media file:
- WordPress rewrites the URL to point to your GCS bucket or CDN domain.
🔧 Usage
-
Upload media as usual via Media → Add New in WordPress.
-
Uploaded files will automatically sync to Google Cloud Storage.
-
Access files directly from:
- https://storage.googleapis.com/bucket-name/path/to/file.jpg
- or your custom domain if configured.
✅ Requirements
PHP 7.4+ (recommended 8.x)
WordPress 5.0+
Google Cloud Project with a valid service account & GCS bucket
google/cloud-storage PHP SDK (installed via composer)
Install dependencies (if not bundled):
bash command : composer require google/cloud-storage