diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 6c3f6c4..90ca0d1 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -1,4 +1,6 @@ framework: + php_errors: + log: true session: storage_factory_id: session.storage.factory.mock_file csrf_protection: ~ diff --git a/resources/init/basic/compose.yaml b/resources/init/basic/compose.yaml index c09c1cc..62dd082 100644 --- a/resources/init/basic/compose.yaml +++ b/resources/init/basic/compose.yaml @@ -3,6 +3,9 @@ services: image: darthsim/imgproxy:v3 environment: - IMGPROXY_LOCAL_FILESYSTEM_ROOT=/app + - IMGPROXY_MAX_ANIMATION_FRAMES=60 + - IMGPROXY_ENABLE_AVIF_DETECTION=1 + - IMGPROXY_ENABLE_WEBP_DETECTION=1 working_dir: /app ports: - 8090:8080 diff --git a/src/AssetQueue.php b/src/AssetQueue.php index 84ff9e1..c10aa02 100644 --- a/src/AssetQueue.php +++ b/src/AssetQueue.php @@ -47,7 +47,11 @@ public function flush(?callable $callable = null): array // TODO: ImgProxy if ($specification instanceof AssetFetch) { - $response = $this->httpClient->request('GET', $specification->url); + $response = $this->httpClient->request('GET', $specification->url, [ + 'headers' => [ + 'Accept' => 'image/webp,image/apng,image/*,*/*;q=0.8', + ], + ]); $this->filesystem->mkdir(\dirname($destination)); $handle = fopen($destination, 'w'); if ($handle === false) { diff --git a/src/Bridge/Twig/Extension/ThumbnailExtension.php b/src/Bridge/Twig/Extension/ThumbnailExtension.php index b9fc636..a79bc1e 100644 --- a/src/Bridge/Twig/Extension/ThumbnailExtension.php +++ b/src/Bridge/Twig/Extension/ThumbnailExtension.php @@ -83,7 +83,7 @@ public function getFunctions(): array return $url; } - $path = \dirname($relative).'/'.md5(md5_file($path).$filter); + $path = sprintf('%1$s/%2$s.%3$s.webp', \dirname($relative), pathinfo($relative, \PATHINFO_FILENAME), mb_substr(md5(md5_file($path).$filter), 0, 8)); $this->thumbnailQueue->add(new AssetFetch($url, $path)); return $this->packages->getUrl(ltrim($path, '/')); diff --git a/tests/functional/site/compose.yaml b/tests/functional/site/compose.yaml index c09c1cc..62dd082 100644 --- a/tests/functional/site/compose.yaml +++ b/tests/functional/site/compose.yaml @@ -3,6 +3,9 @@ services: image: darthsim/imgproxy:v3 environment: - IMGPROXY_LOCAL_FILESYSTEM_ROOT=/app + - IMGPROXY_MAX_ANIMATION_FRAMES=60 + - IMGPROXY_ENABLE_AVIF_DETECTION=1 + - IMGPROXY_ENABLE_WEBP_DETECTION=1 working_dir: /app ports: - 8090:8080 diff --git a/tests/functional/site/fixtures/content/articles/images/200ad8764a311b8ca90c5271eaf73efb b/tests/functional/site/fixtures/content/articles/images/200ad8764a311b8ca90c5271eaf73efb deleted file mode 100644 index d57cb63..0000000 Binary files a/tests/functional/site/fixtures/content/articles/images/200ad8764a311b8ca90c5271eaf73efb and /dev/null differ diff --git a/tests/functional/site/fixtures/content/articles/images/509b6b4c27eb27d81e17c4038e7ad88b b/tests/functional/site/fixtures/content/articles/images/509b6b4c27eb27d81e17c4038e7ad88b deleted file mode 100644 index 6e34e4d..0000000 Binary files a/tests/functional/site/fixtures/content/articles/images/509b6b4c27eb27d81e17c4038e7ad88b and /dev/null differ diff --git a/tests/functional/site/fixtures/content/articles/images/8514a44ac6072de0665dcd273f694d28 b/tests/functional/site/fixtures/content/articles/images/8514a44ac6072de0665dcd273f694d28 deleted file mode 100644 index 409f4ed..0000000 Binary files a/tests/functional/site/fixtures/content/articles/images/8514a44ac6072de0665dcd273f694d28 and /dev/null differ diff --git a/tests/functional/site/fixtures/content/articles/images/image.200ad876.webp b/tests/functional/site/fixtures/content/articles/images/image.200ad876.webp new file mode 100644 index 0000000..07cf990 Binary files /dev/null and b/tests/functional/site/fixtures/content/articles/images/image.200ad876.webp differ diff --git a/tests/functional/site/fixtures/content/articles/images/image.509b6b4c.webp b/tests/functional/site/fixtures/content/articles/images/image.509b6b4c.webp new file mode 100644 index 0000000..8b1104e Binary files /dev/null and b/tests/functional/site/fixtures/content/articles/images/image.509b6b4c.webp differ diff --git a/tests/functional/site/fixtures/content/articles/images/image.8514a44a.webp b/tests/functional/site/fixtures/content/articles/images/image.8514a44a.webp new file mode 100644 index 0000000..20339ce Binary files /dev/null and b/tests/functional/site/fixtures/content/articles/images/image.8514a44a.webp differ diff --git a/tests/functional/site/fixtures/en/article/images/index.html b/tests/functional/site/fixtures/en/article/images/index.html index 02bf083..f01e93b 100644 --- a/tests/functional/site/fixtures/en/article/images/index.html +++ b/tests/functional/site/fixtures/en/article/images/index.html @@ -43,8 +43,8 @@
This is a database lookup example: Hello World!
-This is an asset lookup: /sub/dir/another/content/articles/images/509b6b4c27eb27d81e17c4038e7ad88b
- +This is an asset lookup: /sub/dir/another/content/articles/images/image.509b6b4c.webp
+ diff --git a/tests/functional/site/fixtures/en/articles/1/index.html b/tests/functional/site/fixtures/en/articles/1/index.html index 4441d6d..38559b4 100644 --- a/tests/functional/site/fixtures/en/articles/1/index.html +++ b/tests/functional/site/fixtures/en/articles/1/index.html @@ -16,7 +16,7 @@