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']); + } +}