Fix article image caption if HTML is used in image caption
authorMatthias Schmidt <gravatronics@live.com>
Fri, 3 Jan 2020 15:30:45 +0000 (16:30 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 3 Jan 2020 15:30:45 +0000 (16:30 +0100)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/templates/ampArticle.tpl
com.woltlab.wcf/templates/article.tpl
wcfsetup/install/files/lib/data/media/ViewableMedia.class.php

index 7f34cd5bab72d6c7918d79870a887ff30ed1709f..6dddcb0c42c12d576213d4aa04e659de52b4b579 100644 (file)
                </type>
                <!-- /trophy list box condition -->
                <!-- media -->
+               <type>
+                       <name>com.woltlab.wcf.media.caption</name>
+                       <definitionname>com.woltlab.wcf.message</definitionname>
+               </type>
                <type>
                        <name>com.woltlab.wcf.media</name>
                        <definitionname>com.woltlab.wcf.acl.simple</definitionname>
index fc04826a6b3b866a716e86673a47b6e5419c4852..160f460e893489da307404eb42fc158de6655925 100644 (file)
                <figure class="articleImage">
                        <amp-img src="{$articleContent->getImage()->getThumbnailLink('large')}" alt="{$articleContent->getImage()->altText}" height="{@$articleContent->getImage()->getThumbnailHeight('large')}" width="{@$articleContent->getImage()->getThumbnailWidth('large')}" layout="responsive"></amp-img>
                        {if $articleContent->getImage()->caption}
-                               <figcaption>{$articleContent->getImage()->caption}</figcaption>
+                               <figcaption>
+                                       {if $articleContent->getImage()->captionEnableHtml}
+                                               {@$articleContent->getImage()->getAmpCaption()}
+                                       {else}
+                                               {$articleContent->getImage()->caption}
+                                       {/if}
+                               </figcaption>
                        {/if}
                </figure>
        {/if}
index 3a66b24855a0dcba97781c4da25d3bb0f7a45936..66025219114a08af766ada9ae408360decbd6e95 100644 (file)
                        <figure class="articleImage">
                                <div class="articleImageWrapper">{@$articleContent->getImage()->getThumbnailTag('large')}</div>
                                {if $articleContent->getImage()->caption}
-                                       <figcaption itemprop="description">{$articleContent->getImage()->caption}</figcaption>
+                                       <figcaption itemprop="description">
+                                               {if $articleContent->getImage()->captionEnableHtml}
+                                                       {@$articleContent->getImage()->caption}
+                                               {else}
+                                                       {$articleContent->getImage()->caption}
+                                               {/if}
+                                       </figcaption>
                                {/if}
                        </figure>
                        <meta itemprop="url" content="{$articleContent->getImage()->getThumbnailLink('large')}">
index 39289a64b229c6713c90b811d7eb6d6884204ebd..fb417dfd7e7e89f78cd87b46a4e5822faca1b219 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\data\media;
 use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\html\output\AmpHtmlOutputProcessor;
 use wcf\util\FileUtil;
 use wcf\util\StringUtil;
 
@@ -225,6 +226,19 @@ class ViewableMedia extends DatabaseObjectDecorator {
                return $this->userProfile;
        }
        
+       /**
+        * Returns the amp version of the caption.
+        * 
+        * @return      string
+        * @since       5.2
+        */
+       public function getAmpCaption() {
+               $processor = new AmpHtmlOutputProcessor();
+               $processor->process($this->caption, 'com.woltlab.wcf.media.caption', $this->mediaID);
+               
+               return $processor->getHtml();
+       }
+       
        /**
         * Returns the viewable media file with the given id.
         *