spacecatninja / imager-x-gcs-storage-driver
External storage driver for Imager X that integrates with Google Cloud Services
Package info
github.com/spacecatninja/craft-imager-x-gcs-storage-driver
Type:craft-plugin
pkg:composer/spacecatninja/imager-x-gcs-storage-driver
Requires
- php: ^8.0
- craftcms/cms: ^5.0.0
- google/cloud-storage: ~1.0
- spacecatninja/imager-x: ^6.0.0-beta
README
External storage driver for Imager X that uploads transformed images to Google Cloud Storage.
Requirements
- Craft CMS 5.0.0 or later
- Imager X 6.0.0 or later (Pro edition)
Installation
composer require spacecatninja/imager-x-gcs-storage-driver php craft plugin/install imager-x-gcs-storage-driver
Configuration
Add a gcs key to storageConfig in your config/imager-x.php:
'storages' => ['gcs'], 'storageConfig' => [ 'gcs' => [ 'keyFile' => '', 'bucket' => 'my-bucket', 'folder' => 'transforms', ], ],
Point imagerUrl at your bucket:
'imagerUrl' => 'https://storage.googleapis.com/my-bucket/transforms/',
Always flush your Imager transforms cache when adding or removing external storages, as existing cached transforms will not be re-uploaded.
Configuration options
| Option | Default | Description |
|---|---|---|
keyFile |
'' |
Service account credentials as a JSON string, a path to a JSON key file, or an environment variable reference (e.g. $GCS_KEY). |
bucket |
'' |
GCS bucket name. |
folder |
'' |
Folder prefix within the bucket. |
Authentication
The keyFile setting accepts two formats:
JSON string — pass the service account JSON directly (or via an environment variable):
'keyFile' => '$GOOGLE_APPLICATION_CREDENTIALS_JSON',
File path — pass the path to a service account key file:
'keyFile' => '/var/secrets/gcs-key.json',
Uploaded objects are set to publicRead ACL. Make sure your bucket is configured to allow public access if you intend to serve transforms directly from GCS.
Price, license and support
The plugin is released under the MIT license. It requires Imager X Pro, which is a commercial plugin available in the Craft plugin store.