From ee70120b05676099cee88aa3d14dd3e237bdb838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20R=C3=BCtter?= Date: Sat, 4 Jul 2026 10:55:37 +0000 Subject: [PATCH] Fix glide:data_url reading from the wrong glide cache during generation Co-Authored-By: Claude Fable 5 --- src/Generator.php | 8 ++++++++ tests/GenerateGlideDataUrlTest.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/GenerateGlideDataUrlTest.php diff --git a/src/Generator.php b/src/Generator.php index a4d1593..f0919f2 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -128,6 +128,14 @@ public function bindGlide() new Flysystem(new LocalFilesystemAdapter($this->config['destination'].'/'.$directory)) ); + // Point the glide cache disk to the same location, so that anything + // reading generated images back (e.g. the glide:data_url tag) will + // find them where the server wrote them. + config([ + 'statamic.assets.image_manipulation.cache' => true, + 'statamic.assets.image_manipulation.cache_path' => $this->config['destination'].'/'.$directory, + ]); + $this->app->bind(UrlBuilder::class, function () use ($directory) { return new StaticUrlBuilder($this->app[ImageGenerator::class], [ 'route' => URL::tidy($this->config['base_url'].'/'.$directory), diff --git a/tests/GenerateGlideDataUrlTest.php b/tests/GenerateGlideDataUrlTest.php new file mode 100644 index 0000000..30e2e43 --- /dev/null +++ b/tests/GenerateGlideDataUrlTest.php @@ -0,0 +1,28 @@ +files->put(public_path('image.png'), base64_decode(self::ONE_PIXEL_PNG)); + + $this->files->put( + base_path('resources/views/articles/show.antlers.html'), + '' + ); + + $files = $this->generate(); + + $this->assertStringContainsString('src="data:image/png;base64,', $files['articles/one/index.html']); + } +}