diff --git a/.github/DESIGN_DOCS/resizer.htm b/.github/DESIGN_DOCS/resizer.htm new file mode 100644 index 000000000..69afa6c59 --- /dev/null +++ b/.github/DESIGN_DOCS/resizer.htm @@ -0,0 +1,91 @@ +== +get($targetFile); + + if ($resized) { + return $resized; + } else { + return false; + } + } + + public function resize() + { + + } +} + +// Twig filter implementation +function filterResize(mixed $image, int $width, int $height, array $options) { + $image = Helper::normalizeImage($image); + + $identifier = Helper::getIdentifier(['disk' => $image->disk, 'path' => $image->path], $width, $height, $options); + + if (Helper::resized($identifier)) { + return Helper::resized($identifier)->url(); + } else { + return '/resize/' . $identifier; + } +} + +// Route handling for /resize/{identifier} route +Route::get('/resize/{identifier}', function ($identifier) { + if (Helper::resized($identifier)) { + return redirect()->to(Helper::resized($identifier)); + } + + return Helper::resize($identifier); +}); +== +{##} +{{ 'assets/images/logo.png' | theme | resize(false, false, {quality: 90}) }} +{{ record.mediafinder_field | media | resize(200, false) }} +{{ record.filemodel_property | resize(false, 200, {mode: 'contain'}) }} +{{ record.filemodel_property.getPath() | resize(600, 202) }} \ No newline at end of file