This commit is contained in:
Jürgen Mummert
2025-12-23 12:35:01 +01:00
parent 22c6a3e0b6
commit 872a242794
2 changed files with 8 additions and 12 deletions
-2
View File
@@ -10,5 +10,3 @@ services:
tags:
- { name: contao.hook, hook: indexPage, method: onIndexPage }
Contao\CoreBundle\Filesystem\FilesystemInterface:
alias: filesStorage
+8 -10
View File
@@ -2,39 +2,37 @@
namespace MummertMedia\ContaoMeilisearchBundle\Service;
use Contao\CoreBundle\Filesystem\FilesystemInterface;
use Contao\Image\Studio;
use Contao\Config;
use Contao\FilesModel;
use Contao\Image\Studio;
class MeilisearchImageHelper
{
public function __construct(
private readonly FilesystemInterface $filesStorage,
private readonly Studio $imageStudio,
) {}
public function getImagePathFromUuid(string $uuid): ?string
{
// UUID → Datei
if (!$this->filesStorage->fileExists($uuid)) {
$file = FilesModel::findByUuid($uuid);
if ($file === null) {
return null;
}
$file = $this->filesStorage->get($uuid);
$path = $file->getPath();
$path = $file->path;
// SVG: nicht skalieren
// SVG niemals skalieren
if (str_ends_with(strtolower($path), '.svg')) {
return '/' . ltrim($path, '/');
}
// Bildgröße aus tl_settings
$sizeId = (int) Config::get('meilisearch_imagesize');
if ($sizeId <= 0) {
return '/' . ltrim($path, '/');
}
// Bild über Image Studio erzeugen
$figure = $this->imageStudio
->createFigure($uuid)
->setSize($sizeId)