[BUGFIX] MediaViewHelper does not render data-focus-area attribute 19/51919/4
authorJörg Bösche <typo3@joergboesche.de>
Wed, 1 Mar 2017 14:32:59 +0000 (15:32 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 8 Mar 2017 11:59:58 +0000 (12:59 +0100)
The media view helper should support the new data-focus-area attribute
for image manipulation. Just like the ImageViewHelper does.

Resolves: #80081
Releases: master
Change-Id: I89395ae974b72522d1c4c97d0dae38dd65495ae3
Reviewed-on: https://review.typo3.org/51919
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Helmut Hummel <typo3@helhum.io>
Tested-by: Helmut Hummel <typo3@helhum.io>
Reviewed-by: Claus Due <claus@phpmind.net>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php

index c6f8f5e..54ecf2d 100644 (file)
@@ -145,8 +145,11 @@ class ImageViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedV
             $processedImage = $this->imageService->applyProcessingInstructions($image, $processingInstructions);
             $imageUri = $this->imageService->getImageUri($processedImage, $this->arguments['absolute']);
 
-            if (!$cropVariantCollection->getFocusArea($cropVariant)->isEmpty()) {
-                $this->tag->addAttribute('data-focus-area', $cropVariantCollection->getFocusArea($cropVariant)->makeAbsoluteBasedOnFile($image));
+            if (!$this->tag->hasAttribute('data-focus-area')) {
+                $focusArea = $cropVariantCollection->getFocusArea($cropVariant);
+                if (!$focusArea->isEmpty()) {
+                    $this->tag->addAttribute('data-focus-area', $focusArea->makeAbsoluteBasedOnFile($image));
+                }
             }
             $this->tag->addAttribute('src', $imageUri);
             $this->tag->addAttribute('width', $processedImage->getProperty('width'));
index 6bfaaad..0e8f6e7 100644 (file)
@@ -132,6 +132,12 @@ class MediaViewHelper extends AbstractTagBasedViewHelper
         $processedImage = $imageService->applyProcessingInstructions($image, $processingInstructions);
         $imageUri = $imageService->getImageUri($processedImage);
 
+        if (!$this->tag->hasAttribute('data-focus-area')) {
+            $focusArea = $cropVariantCollection->getFocusArea($cropVariant);
+            if (!$focusArea->isEmpty()) {
+                $this->tag->addAttribute('data-focus-area', $focusArea->makeAbsoluteBasedOnFile($image));
+            }
+        }
         $this->tag->addAttribute('src', $imageUri);
         $this->tag->addAttribute('width', $processedImage->getProperty('width'));
         $this->tag->addAttribute('height', $processedImage->getProperty('height'));