Bugfix
This commit is contained in:
@@ -10,5 +10,3 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: contao.hook, hook: indexPage, method: onIndexPage }
|
- { name: contao.hook, hook: indexPage, method: onIndexPage }
|
||||||
|
|
||||||
Contao\CoreBundle\Filesystem\FilesystemInterface:
|
|
||||||
alias: filesStorage
|
|
||||||
@@ -2,39 +2,37 @@
|
|||||||
|
|
||||||
namespace MummertMedia\ContaoMeilisearchBundle\Service;
|
namespace MummertMedia\ContaoMeilisearchBundle\Service;
|
||||||
|
|
||||||
use Contao\CoreBundle\Filesystem\FilesystemInterface;
|
|
||||||
use Contao\Image\Studio;
|
|
||||||
use Contao\Config;
|
use Contao\Config;
|
||||||
|
use Contao\FilesModel;
|
||||||
|
use Contao\Image\Studio;
|
||||||
|
|
||||||
class MeilisearchImageHelper
|
class MeilisearchImageHelper
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly FilesystemInterface $filesStorage,
|
|
||||||
private readonly Studio $imageStudio,
|
private readonly Studio $imageStudio,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function getImagePathFromUuid(string $uuid): ?string
|
public function getImagePathFromUuid(string $uuid): ?string
|
||||||
{
|
{
|
||||||
// UUID → Datei
|
$file = FilesModel::findByUuid($uuid);
|
||||||
if (!$this->filesStorage->fileExists($uuid)) {
|
|
||||||
|
if ($file === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $this->filesStorage->get($uuid);
|
$path = $file->path;
|
||||||
$path = $file->getPath();
|
|
||||||
|
|
||||||
// SVG: nicht skalieren
|
// SVG → niemals skalieren
|
||||||
if (str_ends_with(strtolower($path), '.svg')) {
|
if (str_ends_with(strtolower($path), '.svg')) {
|
||||||
return '/' . ltrim($path, '/');
|
return '/' . ltrim($path, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bildgröße aus tl_settings
|
|
||||||
$sizeId = (int) Config::get('meilisearch_imagesize');
|
$sizeId = (int) Config::get('meilisearch_imagesize');
|
||||||
|
|
||||||
if ($sizeId <= 0) {
|
if ($sizeId <= 0) {
|
||||||
return '/' . ltrim($path, '/');
|
return '/' . ltrim($path, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bild über Image Studio erzeugen
|
|
||||||
$figure = $this->imageStudio
|
$figure = $this->imageStudio
|
||||||
->createFigure($uuid)
|
->createFigure($uuid)
|
||||||
->setSize($sizeId)
|
->setSize($sizeId)
|
||||||
|
|||||||
Reference in New Issue
Block a user