From 4eae63bd6139f51fd27bc05c7738d7e74411a151 Mon Sep 17 00:00:00 2001
From: Oliver Hader <oliver@typo3.org>
Date: Wed, 20 Jan 2016 19:22:36 +0100
Subject: [PATCH] [BUGFIX] Apply image cropping to click-enlarged images

Image cropping is not applied to click-enlarged images, neither if
using the lightbox-mode nor the regular mode using tx_cms_showpic.
Cropping is applied in these scenarios as well with transporting
the accordant crop value of the current image being processed.

Resolves: #72798
Releases: master, 7.6
Change-Id: I3e07fc447ac8a35cbe4fbb43bac9adb9bb7ed506
Reviewed-on: https://review.typo3.org/46114
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
---
 .../Configuration/TypoScript/v7/setup.txt                  | 1 +
 typo3/sysext/css_styled_content/static/setup.txt           | 1 +
 .../TypoScript/Static/Setup/lib.fluidContent.ts            | 1 +
 .../Classes/ContentObject/ContentObjectRenderer.php        | 2 +-
 .../frontend/Classes/Controller/ShowImageController.php    | 7 ++++++-
 5 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/css_styled_content/Configuration/TypoScript/v7/setup.txt b/typo3/sysext/css_styled_content/Configuration/TypoScript/v7/setup.txt
index 707b095cd122..a94c34b78ee3 100644
--- a/typo3/sysext/css_styled_content/Configuration/TypoScript/v7/setup.txt
+++ b/typo3/sysext/css_styled_content/Configuration/TypoScript/v7/setup.txt
@@ -712,6 +712,7 @@ tt_content.image.20 {
 			width = {$styles.content.imgtext.linkWrap.width}
 			height = {$styles.content.imgtext.linkWrap.height}
 			effects = {$styles.content.imgtext.linkWrap.effects}
+			crop.data = file:current:crop
 
 			JSwindow = 1
 			JSwindow.newWindow = {$styles.content.imgtext.linkWrap.newWindow}
diff --git a/typo3/sysext/css_styled_content/static/setup.txt b/typo3/sysext/css_styled_content/static/setup.txt
index ad1806a1bc7b..e419935f4a4a 100644
--- a/typo3/sysext/css_styled_content/static/setup.txt
+++ b/typo3/sysext/css_styled_content/static/setup.txt
@@ -712,6 +712,7 @@ tt_content.image.20 {
 			width = {$styles.content.imgtext.linkWrap.width}
 			height = {$styles.content.imgtext.linkWrap.height}
 			effects = {$styles.content.imgtext.linkWrap.effects}
+			crop.data = file:current:crop
 
 			JSwindow = 1
 			JSwindow.newWindow = {$styles.content.imgtext.linkWrap.newWindow}
diff --git a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts
index 6fceae14de94..00308ef3d1dc 100644
--- a/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts
+++ b/typo3/sysext/fluid_styled_content/Configuration/TypoScript/Static/Setup/lib.fluidContent.ts
@@ -24,6 +24,7 @@ lib.fluidContent {
 				wrap = <a href="javascript:close();"> | </a>
 				width = {$styles.content.textmedia.linkWrap.width}
 				height = {$styles.content.textmedia.linkWrap.height}
+				crop.data = file:current:crop
 
 				JSwindow = 1
 				JSwindow {
diff --git a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
index ea9be1157346..43da6b1d6c6c 100644
--- a/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
+++ b/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
@@ -1397,7 +1397,7 @@ class ContentObjectRenderer
 
         // Create imageFileLink if not created with typolink
         if ($content === $string) {
-            $parameterNames = array('width', 'height', 'effects', 'bodyTag', 'title', 'wrap');
+            $parameterNames = array('width', 'height', 'effects', 'bodyTag', 'title', 'wrap', 'crop');
             $parameters = array();
             $sample = isset($conf['sample.']) ? $this->stdWrap($conf['sample'], $conf['sample.']) : $conf['sample'];
             if ($sample) {
diff --git a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
index 3c366912ee68..50526efd8446 100644
--- a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
+++ b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php
@@ -56,6 +56,11 @@ class ShowImageController
      */
     protected $height;
 
+    /**
+     * @var string
+     */
+    protected $crop;
+
     /**
      * @var int
      */
@@ -178,7 +183,7 @@ EOF;
             'width' => $this->width,
             'height' => $this->height,
             'frame' => $this->frame,
-
+            'crop' => $this->crop,
         );
         return $this->file->process('Image.CropScaleMask', $processingConfiguration);
     }
-- 
GitLab