paul-blundell/craft3-glide

There is no license information available for the latest version (1.0.5) of this package.

Add Glide support to Craft 3

1.0.5 2022-01-10 17:31 UTC

This package is auto-updated.

Last update: 2024-04-10 22:45:39 UTC


README

On-demand image manipulation for Craft 3 using Glide 1.0 from The PHP League.

Example Usage

<img src="/glide/myimage.jpg?w=100&h=200" alt="My Image" />

If your asset uploaded to craft is mysite.com/assets/img/animage.jpg then this can now be rendered with Glide at mysite.com/glide/animage.jpg?w=100

For more information about what parameters are supported please see the Glide website.

Installation

composer require paul-blundell/craft3-glide

Set your Local Asset Volume base URL to the following;

https://your-domain.com/path-to-craft/glide/

CDN / Advanced Usage

I strongly recommend using Imgix if your budget will allow it. It works in a similar way to this plugin but with a few nice extra features and all responses are served via CDN.

This plugin was never intended to replace Imgix, Cloudinary, etc. but rather is aimed at smaller projects with tighter budgets that need more flexibility than Crafts native transforms.

It should be possible to create a CDN distribution using your domain as the origin, just make sure Query String Forwarding is enabled.

Security

By signing each request with a private key, no alterations can be made to the URL parameters.

Create the file config/glide.php with the following:

<?php

return [
    'signed' => true,
    'key' => 'random-long-string',
];

Then you can use this service to generate the URL:

\blundell\glide\Plugin::getInstance()->render->url('image.jpg', ['w' => '100']);

Or with Twig:

<img src="{{ craft.glide.url('wedding.jpg', {w: 500}) }}" alt="My Image" />

Roadmap

  • Add support for non-local asset volumes
  • Update to Glide 2.0