浏览代码

fix image provider

Olivier Massot 7 月之前
父节点
当前提交
b4878be3f7
共有 2 个文件被更改,包括 8 次插入3 次删除
  1. 1 1
      src/Service/File/Factory/ImageFactory.php
  2. 7 2
      src/Service/File/Storage/LocalStorage.php

+ 1 - 1
src/Service/File/Factory/ImageFactory.php

@@ -30,7 +30,7 @@ class ImageFactory
     public function createImageContent(File $file, string $filterName): void
     public function createImageContent(File $file, string $filterName): void
     {
     {
         $filters_options = $this->getCropFilterOptions($file->getConfig());
         $filters_options = $this->getCropFilterOptions($file->getConfig());
-        $path = $file->getPath();
+        $path = $file->getSlug();
         $this->createAndStore($path, $filterName, $filters_options);
         $this->createAndStore($path, $filterName, $filters_options);
     }
     }
 
 

+ 7 - 2
src/Service/File/Storage/LocalStorage.php

@@ -96,7 +96,7 @@ class LocalStorage implements FileStorageInterface
     public function getImageUrl(File $file, string $size, bool $relativePath): string
     public function getImageUrl(File $file, string $size, bool $relativePath): string
     {
     {
         $filterName = $this->getFilterFromSizeAndConfig($size, !empty($file->getConfig()));
         $filterName = $this->getFilterFromSizeAndConfig($size, !empty($file->getConfig()));
-        $path = $file->getPath();
+        $path = $file->getSlug();
 
 
         if (!$this->cacheManager->isStored($path, $filterName)) {
         if (!$this->cacheManager->isStored($path, $filterName)) {
             try {
             try {
@@ -191,7 +191,12 @@ class LocalStorage implements FileStorageInterface
             throw new \RuntimeException('File has no filename');
             throw new \RuntimeException('File has no filename');
         }
         }
 
 
-        $isNewFile = $file->getSlug() === null;
+        try {
+            $isNewFile = $file->getSlug() === null;
+        } catch (\Throwable) {
+            $isNewFile = true; // Catch case where slud has not been initialized
+        }
+
         if ($isNewFile) {
         if ($isNewFile) {
             // Try to get the Access owner from the organization_id and person_id
             // Try to get the Access owner from the organization_id and person_id
             $access = null;
             $access = null;