Sfoglia il codice sorgente

adapt to new Liip image system

Olivier Massot 1 anno fa
parent
commit
760aa3447f

+ 1 - 1
ot_core/Classes/Domain/Repository/DonorRepository.php

@@ -65,7 +65,7 @@ class DonorRepository extends BaseApiRepository
         $donor->setWebsite($record['website']);
         $donor->setWording($record['wording']);
         $donor->setDisplayedOn($record['displayedOn']);
-        $donor->setLogo($record['logo'] ?? null);
+        $donor->setLogo($record['logo'] ? $this->apiService->getApiUri($record['logo'], true) : null);
 
         return $donor;
     }

+ 1 - 1
ot_core/Classes/Domain/Repository/EventRepository.php

@@ -190,7 +190,7 @@ class EventRepository extends BaseApiRepository
         $event->setRoomFloorSize($record['roomFloorSize']);
         $event->setZupId($record['zupId']);
         $event->setDeepLink($record['deepLink']);
-        $event->setImage($record['image']);
+        $event->setImage($record['image'] ? $this->apiService->getApiUri($record['image'], true) : null);
         $event->setPriceMini($record['priceMini']);
         $event->setMeetingSchedule($record['meetingSchedule']);
         $event->setApi($record['api']);

+ 1 - 3
ot_core/Classes/Domain/Repository/FederationStructureRepository.php

@@ -62,9 +62,7 @@ class FederationStructureRepository extends BaseApiRepository
         $federationStructure->setLongitude($record['longitude']);
         $federationStructure->setCountry($record['country']);
         $federationStructure->setCategories($record['categories']);
-        if ($record['logoId']) {
-            $federationStructure->setLogoUri($this->apiService->getApiUri('_internal/secure/files/') . $record['logoId']);
-        }
+        $federationStructure->setLogoUri($record['logoId']);
         $federationStructure->setParentId($record['n1Id']);
         $federationStructure->setParentName($record['n1Name']);
         $federationStructure->setParents($record['parents']);

+ 1 - 1
ot_core/Classes/Domain/Repository/MemberRepository.php

@@ -64,7 +64,7 @@ class MemberRepository extends BaseApiRepository
             $member->setMission($record['mission']);
         }
         $member->setPersonId((int)$record['personId']);
-        $member->setImage($record['image']);
+        $member->setImage($record['image'] ? $this->apiService->getApiUri($record['image'], true) : null);
 
         return $member;
     }

+ 1 - 1
ot_core/ext_emconf.php

@@ -15,7 +15,7 @@ $EM_CONF[$_EXTKEY] = [
     'author' => 'Olivier Massot',
     'author_email' => 'olivier.massot@2iopenservice.fr',
     'state' => 'stable',
-    'version' => '0.7',
+    'version' => '0.7.1',
     'constraints' => [
         'depends' => [
             'typo3' => '10.4.0-11.5.99',

+ 2 - 9
ot_templating/Classes/ViewHelpers/GetImageUrlViewHelper.php → ot_templating/Classes/ViewHelpers/Image/GetSrcByIdViewHelper.php

@@ -1,17 +1,10 @@
 <?php
 
-namespace Opentalent\OtTemplating\ViewHelpers;
+namespace Opentalent\OtTemplating\ViewHelpers\Image;
 
 
-use Closure;
 use Opentalent\OtCore\Service\OpentalentImageService;
-use Opentalent\OtCore\Website\OtPageRepository;
 use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
-use Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Object\ObjectManager;
-use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
-use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
 
 /**
  * Returns the url of the requested image
@@ -23,7 +16,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
  * @see ot_core/Classes/Service/OpentalentImageService.php
  * @package Opentalent\OtTemplating\ViewHelpers
  */
-class GetImageUrlViewHelper extends OtAbstractViewHelper
+class GetSrcByIdViewHelper extends OtAbstractViewHelper
 {
     public OpentalentImageService $opentalentImageService;
 

+ 59 - 0
ot_templating/Classes/ViewHelpers/Image/GetSrcByPathViewHelper.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace Opentalent\OtTemplating\ViewHelpers\Image;
+
+
+use Opentalent\OtCore\Exception\ApiRequestException;
+use Opentalent\OtCore\Service\OpentalentApiService;
+use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
+
+/**
+ * Returns the absolute url of the requested image
+ *
+ *     {namespace ot=Opentalent\OtTemplating\ViewHelpers}
+ *
+ *     {ot:image.getByUrl(path: "/media/cache/crop_md/organization/123/upload/my_picture.jpg")}
+ *
+ * @see ot_core/Classes/Service/OpentalentImageService.php
+ * @package Opentalent\OtTemplating\ViewHelpers
+ */
+class GetSrcByPathViewHelper extends OtAbstractViewHelper
+{
+    public OpentalentApiService $opentalentApiService;
+
+    /**
+     * @param OpentalentApiService $opentalentApiService
+     * @return void
+     */
+    public function injectOpentalentApiService(OpentalentApiService $opentalentApiService)
+    {
+        $this->opentalentApiService = $opentalentApiService;
+    }
+
+    /**
+     * -- This method is expected by Fluid --
+     * Declares the viewhelper's parameters
+     */
+    public function initializeArguments()
+    {
+        $this->registerArgument(
+            'path',
+            'string',
+            'The path (relative url) of the image in the storage',
+            true
+        );
+    }
+
+    /**
+     * -- This method is expected by Fluid --
+     * Renders the content as html
+     *
+     * @return string
+     * @throws ApiRequestException
+     */
+    public function render()
+    {
+        $path = $this->arguments['path'];
+        return $this->opentalentApiService->getApiUri($path, true);
+    }
+}

+ 1 - 1
ot_templating/Resources/Private/Partials/Classic/EventsIndex.html

@@ -66,7 +66,7 @@
                     <div class="event-poster">
                         <f:if condition="{event.image}">
                             <f:then>
-                                <img src='{event.image}' alt="poster" />
+                                <img src="{event.image}" alt="poster" />
                             </f:then>
                             <f:else>
                                 <f:image src="EXT:ot_templating/Resources/Public/media/event-default.jpg" alt="poster" />

+ 1 - 1
ot_templating/Resources/Private/Partials/Classic/MembersList.html

@@ -12,7 +12,7 @@
                         <p class="ot-member-image">
                             <f:if condition="{member.image}">
                                 <f:then>
-                                    <img src="{member.image}/160x0" alt=""/>
+                                    <img src="{member.image}" alt=""/>
                                 </f:then>
                                 <f:else if="{member.gender}=='MISTER'">
                                     <f:image src="EXT:ot_templating/Resources/Public/media/man-default.jpg"/>

+ 1 - 1
ot_templating/Resources/Private/Partials/Classic/Topbar.html

@@ -6,7 +6,7 @@
     <div class="topbar-logo">
         <f:if condition="{settings.structureLogoId}">
             <a href="{ot:rootPage.getUri()}" title="{settings.structureName}">
-                <img src="{ot:request.getOtEnvVar(argument: 'FILE_STORAGE_URL')}{settings.structureLogoId}" alt="{settings.structureName}"/>
+                <img src="{ot:image.getSrcById(fileId: settings.structureLogoId, size: 'sm')}" alt="{settings.structureName}"/>
             </a>
         </f:if>
     </div>

+ 1 - 1
ot_templating/Resources/Private/Partials/Modern/MembersList.html

@@ -13,7 +13,7 @@
                             <f:if condition="{member.image}">
                                 <f:then>
                                     <f:image class="defer"
-                                             data="{'src':'{member.image}/160x0'}"
+                                             data="{'src':'{member.image}'}"
                                              src="EXT:ot_templating/Resources/Public/media/loading.png"/>
                                 </f:then>
                                 <f:else if="{member.gender}=='MISTER'">

+ 1 - 1
ot_templating/Resources/Private/Partials/Modern/Menu.html

@@ -25,7 +25,7 @@
                                     <f:then>
                                         <a href="{ot:rootPage.getUri()}" title="{settings.structureName}">
                                             <img id="logo_img"
-                                                 src="{ot:getImageUrl(fileId: settings.structureLogoId, size: 'sm')}"
+                                                 src="{ot:image.getSrcById(fileId: settings.structureLogoId, size: 'sm')}"
                                                  alt="{settings.structureName}"/>
                                         </a>
                                     </f:then>