From 95aedc5887e1f00ac05d00a1a831ea054ace982e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 26 Apr 2023 19:43:01 +0200 Subject: [PATCH] Export custom bbcode icons as image src See #5182 --- com.woltlab.wcf/templates/wysiwyg.tpl | 2 +- .../files/lib/data/bbcode/BBCode.class.php | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/com.woltlab.wcf/templates/wysiwyg.tpl b/com.woltlab.wcf/templates/wysiwyg.tpl index b84af7b417..6d44038537 100644 --- a/com.woltlab.wcf/templates/wysiwyg.tpl +++ b/com.woltlab.wcf/templates/wysiwyg.tpl @@ -50,7 +50,7 @@ const bbcodes = [ {foreach from=$__wcf->getBBCodeHandler()->getButtonBBCodes(true) item=__bbcode} { - icon: '{@$__bbcode->wysiwygIcon|encodeJS}', + icon: '{@$__bbcode->getIcon()|encodeJS}', name: '{@$__bbcode->bbcodeTag|encodeJS}', label: '{@$__bbcode->getButtonLabel()|encodeJS}', }, diff --git a/wcfsetup/install/files/lib/data/bbcode/BBCode.class.php b/wcfsetup/install/files/lib/data/bbcode/BBCode.class.php index 10b5870828..09297e434e 100644 --- a/wcfsetup/install/files/lib/data/bbcode/BBCode.class.php +++ b/wcfsetup/install/files/lib/data/bbcode/BBCode.class.php @@ -157,4 +157,26 @@ class BBCode extends ProcessibleDatabaseObject implements IRouteController return true; } + + /** + * Returns the FontAwesome icon string or the URL to the image. + * + * @since 6.0 + */ + public function getIcon(): string + { + if ($this->wysiwygIcon === '') { + return ''; + } + + if (\str_contains($this->wysiwygIcon, ';')) { + return $this->wysiwygIcon; + } + + return \sprintf( + '%sicon/%s', + WCF::getPath(), + $this->wysiwygIcon + ); + } } -- 2.20.1