From: Matthias Schmidt Date: Fri, 3 Jan 2020 15:30:45 +0000 (+0100) Subject: Fix article image caption if HTML is used in image caption X-Git-Tag: 5.2.1~25 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=206dfad0372fc7816c6729725460cd4da957e3f0;p=GitHub%2FWoltLab%2FWCF.git Fix article image caption if HTML is used in image caption --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 7f34cd5bab..6dddcb0c42 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1535,6 +1535,10 @@ + + com.woltlab.wcf.media.caption + com.woltlab.wcf.message + com.woltlab.wcf.media com.woltlab.wcf.acl.simple diff --git a/com.woltlab.wcf/templates/ampArticle.tpl b/com.woltlab.wcf/templates/ampArticle.tpl index fc04826a6b..160f460e89 100644 --- a/com.woltlab.wcf/templates/ampArticle.tpl +++ b/com.woltlab.wcf/templates/ampArticle.tpl @@ -49,7 +49,13 @@
{if $articleContent->getImage()->caption} -
{$articleContent->getImage()->caption}
+
+ {if $articleContent->getImage()->captionEnableHtml} + {@$articleContent->getImage()->getAmpCaption()} + {else} + {$articleContent->getImage()->caption} + {/if} +
{/if}
{/if} diff --git a/com.woltlab.wcf/templates/article.tpl b/com.woltlab.wcf/templates/article.tpl index 3a66b24855..6602521911 100644 --- a/com.woltlab.wcf/templates/article.tpl +++ b/com.woltlab.wcf/templates/article.tpl @@ -133,7 +133,13 @@
{@$articleContent->getImage()->getThumbnailTag('large')}
{if $articleContent->getImage()->caption} -
{$articleContent->getImage()->caption}
+
+ {if $articleContent->getImage()->captionEnableHtml} + {@$articleContent->getImage()->caption} + {else} + {$articleContent->getImage()->caption} + {/if} +
{/if}
diff --git a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php index 39289a64b2..fb417dfd7e 100644 --- a/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php +++ b/wcfsetup/install/files/lib/data/media/ViewableMedia.class.php @@ -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. *