-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Filesystem Disks and Watermarks in Glide #5725
Conversation
# Conflicts: # src/Imaging/GlideServer.php
For watermarks, in the
(not sure if I'm able to contribute to the PR myself - happy to make this change if it's something I'm able to... still new to contributing, sorry) Admittedly these three were missing in my initial PR for watermarks, but were added in a later commit. After upgrading a site that overrode the |
Done. Thanks! |
Is there a reason (with Glide or other) why |
No reason at all. Whoops! |
Woop! Love your stuff 🙃 |
This PR adds support for using any Flysystem disk (defined in
config/filesystems.php
) for the Glide cache.Closes #5143
It also adds support for Glide's watermark feature.
Closes statamic/ideas#84
Cache Disks
You can:
The configuration is explained in more detail on the docs: statamic/docs#791
Absolute URL usage
The
glide
tag currently outputs relative urls by default, and you can opt into absolute URLs using a parameter, like this:If you're using something like S3, it'd be lame to have to add
absolute="true"
to every tag.This PR makes it so that if your Glide route is absolute, all the tags will be absolute by default, without the need for a parameter.
Caching Layer
The way Glide works, it will check the cache filesystem to see if the image has already been generated. That way, it won't try to re-generate it.
If you're using an API based disk like S3, it'll be an API call just to check if a file exists. This definitely causes a slowdown.
To combat this, we will now cache the path once it's generated. Then the next time you use a glide tag, it will check the cache first (which is fast) and not bother making an API call at all.
This Glide cache will be separate from your regular application cache, so that during deployments or other times when you might run
artisan cache:clear
, your Glide cache doesn't get wiped.However, when you run
please glide:clear
, it'll get cleared, as expected.The Glide cache store will be on the local filesystem by default. If you want a custom one (e.g. using redis), you can create a new store in
config/cache.php
namedglide
.Watermarks
You may now provide watermarks to Glide with no additional setup needed. Simply feed it a
mark
parameter, which is a reference to an image, and can be any format that the Glide tag would use as a source.For example, you could give it a relative path, which will assume it's in your
public
directory:a relative URL:
an external URL:
or an asset, by passing a field:
Todo:
glide:generate
tag has some assumptions its on a local disk.glide:clear
command