This commit is contained in:
Jürgen Mummert
2025-12-23 12:43:31 +01:00
parent 9aa3597c2e
commit c71554b18c
2 changed files with 134 additions and 7 deletions
+54 -3
View File
@@ -16,21 +16,51 @@ class MeilisearchImageHelper
public function getImagePathFromUuid(string $uuid): ?string
{
if (PHP_SAPI === 'cli') {
echo "\n[MeilisearchImageHelper]\n";
echo "UUID received: $uuid\n";
}
$file = FilesModel::findByUuid($uuid);
if ($file === null) {
if (PHP_SAPI === 'cli') {
echo "❌ FilesModel::findByUuid() returned NULL\n";
}
return null;
}
if (PHP_SAPI === 'cli') {
echo "✔ File found: {$file->path}\n";
}
// SVG niemals skalieren
if (str_ends_with(strtolower($file->path), '.svg')) {
return '/' . ltrim($file->path, '/');
$path = '/' . ltrim($file->path, '/');
if (PHP_SAPI === 'cli') {
echo "✔ SVG detected, returning original path:\n";
echo "$path\n";
}
return $path;
}
$sizeId = (int) Config::get('meilisearch_imagesize');
if (PHP_SAPI === 'cli') {
echo "Image size ID from tl_settings: $sizeId\n";
}
if ($sizeId <= 0) {
return '/' . ltrim($file->path, '/');
$path = '/' . ltrim($file->path, '/');
if (PHP_SAPI === 'cli') {
echo "⚠ No image size set, returning original path:\n";
echo "$path\n";
}
return $path;
}
$figure = $this->imageStudio
@@ -39,8 +69,29 @@ class MeilisearchImageHelper
->setSize($sizeId)
->build();
if (!$figure) {
if (PHP_SAPI === 'cli') {
echo "❌ Figure build returned NULL\n";
}
return null;
}
$image = $figure->getImage();
return $image ? $image->getImageSrc() : null;
if ($image === null) {
if (PHP_SAPI === 'cli') {
echo "❌ Figure->getImage() returned NULL\n";
}
return null;
}
$src = $image->getImageSrc();
if (PHP_SAPI === 'cli') {
echo "✔ Processed image path:\n";
echo "$src\n";
}
return $src ?: null;
}
}