[FEATURE] Use FAL file properties as default image attributes in RTE
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 3 May 2012 03:03:38 +0000 (23:03 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 3 May 2012 03:06:47 +0000 (05:06 +0200)
Use FAL file properties "name" and "alternative" as default values for
"title" and "alt" img tag attributes when inserting an image into the
RTE content.

Change-Id: If33bfbd26bea5e63e154cd4e042b327eb1e02199
Releases: 6.0
Resolves: #36796
Reviewed-on: http://review.typo3.org/10944
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php

index b8d093c..ec8d6a0 100644 (file)
@@ -248,14 +248,16 @@ class tx_rtehtmlarea_select_image extends browse_links {
                        $table = t3lib_div::_GP('table');
                        $uid = t3lib_div::_GP('uid');
                        $fileObject = t3lib_file_Factory::getInstance()->getFileObject($uid);
-
+                               // Get default values for alt and title attributes from file properties
+                       $altText = $fileObject->getProperty('alternative');
+                       $titleText = $fileObject->getProperty('name');
                        switch ($this->act) {
                                case 'magic':
-                                       $this->insertMagicImage($fileObject, '', '', 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
+                                       $this->insertMagicImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
                                        exit;
                                        break;
                                case 'plain':
-                                       $this->insertPlainImage($fileObject, '', '', 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
+                                       $this->insertPlainImage($fileObject, $altText, $titleText, 'data-htmlarea-file-uid="' . $uid . '" data-htmlarea-file-table="' . $table . '"');
                                        exit;
                                        break;
                                default:
@@ -281,6 +283,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
         */
        public function insertMagicImage(t3lib_file_FileInterface $fileObject, $altText='', $titleText='', $additionalParams='') {
                if ($this->RTEImageStorageDir) {
+                               // Create the magic image
                        /** @var $magicImageService t3lib_file_Service_MagicImageService */
                        $magicImageService = t3lib_div::makeInstance('t3lib_file_Service_MagicImageService');
                        $imageConfiguration = array(