croxton / imgixer

Generate Imgix URLs in Craft 3
MIT License
11 stars 4 forks source link

Looking for a way to use different volumes and one filesystem #17

Open bart-honcho opened 1 week ago

bart-honcho commented 1 week ago

Hi there,

I am looking to create one filesystem that points to the root of my digital ocean spaces folder and then have 3 different volumes each pointing to different folders ie Images, Videos & Files

I understand from this issue: https://github.com/croxton/imgixer/issues/7, that you can add an array to the subfolder path in the config file and that will work, however that slightly defeats the point if I have to update the config each time I create a new site with a new volume

Screenshot 2024-09-19 at 16 11 37

Just wondering if there is a way for imgixer to map to the volume subpath?

Thank you

croxton commented 1 week ago

The best way to do this is to define 3 filesystems and 3 corresponding asset volumes (for Images, Videos & Files) setting the Subfolder on the filesystem rather than specifying a Subpath on the volume. The filesystems can all use the same Base URL and point to the same external cloud storage.

Filesystem:

Screenshot 2024-09-20 at 17 18 55

Asset volume:

Screenshot 2024-09-20 at 17 17 09
croxton commented 1 week ago

You would only need to define a single source to transform images in any of the three subfolders (or any future ones you might create). E.g.:

'imgix' => array(
    'provider' => 'imgix',
    'endpoint' => getenv('IMGIX_URL'),
    'privateKey' => getenv('IMGIX_KEY'),
    'signed' => true,
    'defaultParams' => array(
        'auto' => 'compress,format,enhance',
        'fit'  => 'crop',
        'crop' => 'focalpoint',
        'step' => '256',
        'q'    => '80'
    )
),