spacecatninja / craft-imager-x-imagekit-transformer

ImageKit transformer for Imager X
MIT License
0 stars 2 forks source link

DefaultParams not taking effect #4

Closed terryupton closed 1 year ago

terryupton commented 1 year ago

Hi @aelvan,

I am back to testing Imagekit following your fixes, but I think I have stumbled across another bug issue. I am trying to use defaultParams and these are not taking effect. I have added some radical settings to try and test this. I have tried this in both the profile and top level as follows:


<?php
return [
    'publicKey'      => 'redacted',
    'privateKey'     => 'redacted',
    'profiles'       => [
        'default' => [
            'urlEndpoint'        => 'https://ik.imagekit.io/ibreoxzd1/',
            'isWebProxy'         => false,
            'useCloudSourcePath' => false,
            'addPath'            => [
                'images'   => 'images',
                'projects' => 'projects',
                'staff'    => 'staff',
            ],
            'defaultParams'      => [
                'pr'    => 'true',
                'cp'    => 'true',
                'q'     => 20,
                'focus' => 'face',
                'z'     => '0.9',
                'bg'    => '272B38',
            ],
        ],
    ],
    'defaultProfile' => 'default'

];

I have also tried it like so:


<?php
return [
    'publicKey'      => 'redacted',
    'privateKey'     => 'redacted',
    'defaultParams'      => [
        'pr'    => 'true',
        'cp'    => 'true',
        'q'     => 20,
        'focus' => 'face',
        'z'     => '0.9',
        'bg'    => '272B38',
    ],
    'profiles'       => [
        'default' => [
            'urlEndpoint'        => 'https://ik.imagekit.io/ibreoxzd1/',
            'isWebProxy'         => false,
            'useCloudSourcePath' => false,
            'addPath'            => [
                'images'   => 'images',
                'projects' => 'projects',
                'staff'    => 'staff',
            ],
        ],
    ],
    'defaultProfile' => 'default'

];
aelvan commented 1 year ago

Fixed this issue and various others in 1.1.1.

Please not that you should always use the parameters specified in the "List of supported transformations" in the Imagekit PHP library when available, instead of the direct url params. So instead of what you had:

   'defaultParams'      => [
        'progressive'    => 'true',
        'colorProfile'    => 'true',
        'quality'     => 20,
        'focus' => 'face',
        'z'     => '0.9',
        'background'    => '272B38',
    ],

And you can both have defaultParams at the root level of your config, and in a given profile. The ones in the profile will be merged and overrides the params at the root level.