Skip to content

Instantly share code, notes, and snippets.

@imacrayon
Created March 23, 2023 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imacrayon/17c5bc47c2d49e19768de260cf0a895c to your computer and use it in GitHub Desktop.
Save imacrayon/17c5bc47c2d49e19768de260cf0a895c to your computer and use it in GitHub Desktop.
diff --git a/src/Tags/Glide.php b/src/Tags/Glide.php
--- a/src/Tags/Glide.php
+++ b/src/Tags/Glide.php
@@ -135,7 +135,11 @@
$data = ['url' => $this->generateGlideUrl($item)];
if ($this->isValidExtension($item)) {
- $path = $this->generateImage($item);
+ if (is_string(config('statamic.assets.image_manipulation.cache'))) {
+ $path = Str::removeLeft($data['url'], GlideManager::url().'/');
+ } else {
+ $path = $this->generateImage($item);
+ }
$attrs = Attributes::from(GlideManager::cacheDisk()->getDriver(), $path);
$data = array_merge($data, $attrs);
}
@@ -191,6 +195,15 @@
*/
private function generateGlideUrl($item)
{
+ $item = $this->normalizeItem($item);
+ $params = $this->getGlideParams($item);
+ $manipulationCacheKey = 'asset::'.$item->id().'::'.md5(json_encode($params));
+ if (is_string(config('statamic.assets.image_manipulation.cache'))) {
+ if ($path = GlideManager::cacheStore()->get($manipulationCacheKey)) {
+ return GlideManager::url().'/'.$path;
+ }
+ }
+
try {
$url = $this->isValidExtension($item) ? $this->getManipulator($item)->build() : $this->normalizeItem($item);
} catch (\Exception $e) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment