[FEATURE] Add hook in csc to allow alternative renderings 93/18893/4
authorGeorg Ringer <georg.ringer@gmail.com>
Thu, 14 Mar 2013 08:59:30 +0000 (09:59 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Sun, 14 Apr 2013 08:36:30 +0000 (10:36 +0200)
This hook is needed to render alternative content which is not
just a plain image. I am thinking of showing other FAL content
like videos, things which need to be embedded as JS, ...

Change-Id: Id1f3a21dfbb11fb88fd9384acdd29b445efd4671
Resolves: #46259
Releases: 6.1
Reviewed-on: https://review.typo3.org/18893
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/css_styled_content/Classes/Controller/CssStyledContentController.php

index da4d173..9478a19 100644 (file)
@@ -680,7 +680,30 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
                                        $GLOBALS['TSFE']->ATagParams .= ' title="' . $titleText . '"';
                                }
                        }
-                       if ($imgConf || $imgConf['file']) {
+
+                       // hook to allow custom rendering of a single element
+                       // This hook is needed to render alternative content which is not just a plain image,
+                       // like showing other FAL content, like videos, things which need to be embedded as JS, ...
+                       $customRendering = '';
+                       if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['css_styled_content']['pi1_hooks']['render_singleMediaElement'])
+                               && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['css_styled_content']['pi1_hooks']['render_singleMediaElement'])) {
+                               $hookParameters = array(
+                                       'file' => $totalImagePath,
+                                       'imageConfiguration' => $imgConf
+                               );
+
+                               foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['css_styled_content']['pi1_hooks']['render_singleMediaElement'] as $reference) {
+                                       $customRendering = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($reference, $hookParameters, $this);
+                                       // if there is a renderer found, don't run through the other renderers
+                                       if (!empty($customRendering)) {
+                                               break;
+                                       }
+                               }
+                       }
+
+                       if (!empty($customRendering)) {
+                               $imgsTag[$imgKey] = $customRendering;
+                       } elseif ($imgConf || $imgConf['file']) {
                                if ($this->cObj->image_effects[$image_effects]) {
                                        $imgConf['file.']['params'] .= ' ' . $this->cObj->image_effects[$image_effects];
                                }
@@ -1204,4 +1227,4 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
        }
 
 }
-?>
\ No newline at end of file
+?>