Bugfix
This commit is contained in:
@@ -10,5 +10,3 @@ services:
|
||||
tags:
|
||||
- { name: contao.hook, hook: indexPage, method: onIndexPage }
|
||||
|
||||
Contao\CoreBundle\Filesystem\FilesystemInterface:
|
||||
alias: filesStorage
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user