cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Driver based image manipulation with render tag

Open jasonvarga opened this issue 1 year ago • 2 comments

[!WARNING] This is very much a work in progress.

Currently, all image manipulation is fairly tightly integrated with Glide.

This PR introduces the concept of driver-based image manipulation. Glide will continue to ship as the default, but it will become easier to swap it out for other services such as Imgix, Cloudinary, Cloudflare Images, etc.

This will also introduce a new render tag which will be essentially identical to the glide tag but allow you to use any driver. For example, if you were to use the imgix driver, you'd be able to use their face detection and background removal features:

{{ render:image
    w="100" h="200"
    fit="facearea" faceindex="1" facepad="2"
    bg-remove="true" }}

This is aimed to be introduced in the 5.x line at some point, so everything should be backwards compatible. You will be able to opt into it by either using the new render tag, or by customizing your image manipulation config file.

return [
    'default' => env('STATAMIC_IMAGE_MANIPULATION_DRIVER', 'glide'),

    'manipulators' => [
        'glide' => [
            'driver' => 'glide',
            'library' => 'gd',
            'cache' => public_path('img'),
        ],

        'imgix' => [
            'driver' => 'imgix',
            'url' => 'myaccount.imgix.net',
            'key' => env('IMGIX_KEY'),
        ],
    ],
];
  • [ ] Imgix with multiple asset container handling
  • [ ] Preset "unpacking". Presets are a Glide feature, but they make sense anywhere. We could continue to let you define presets but instead of passing ?p=whatever as a param, it would unpack them and do ?w=100&h=100&etc=
  • [ ] Parameter aliases (e.g. width => w)
  • [x] The magical fit="crop_focal" param only works for glide. Needs to be smarter. e.g. glide wants ?fit=crop-1-1-1 but imgix wants something like ?fit=crop&crop=focalpoint&fp-x=1&fp-y=1&fp-z=1
  • [ ] Container specific drivers,
    • [ ] Log/error appropriately depending on environment
  • [ ] Resolve https://github.com/statamic/cms/issues/8199
  • [ ] Include https://github.com/statamic/cms/pull/10594 somehow

jasonvarga avatar May 28 '24 02:05 jasonvarga

Would this be something in the future where Statamic itself would support a certain number of popular image providers by default? Or would they all be addon based? Just curious because we use Cloudflare images as our image provider.

godismyjudge95 avatar Jul 30 '24 16:07 godismyjudge95

Cloudflare images is probably a good one to also support natively.

jasonvarga avatar Jul 30 '24 17:07 jasonvarga