+{if !$removeLinks|isset}{assign var='removeLinks' value=false}{/if}
<span class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
{if $thumbnailSize != 'original'}
- <a href="{$mediaLink}" class="embeddedAttachmentLink jsImageViewer"><img src="{$thumbnailLink}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->getThumbnailWidth($thumbnailSize)}" data-height="{@$media->getThumbnailHeight($thumbnailSize)}"></a>
+ {if !$removeLinks}<a href="{$mediaLink}" class="embeddedAttachmentLink jsImageViewer">{/if}<img src="{$thumbnailLink}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->getThumbnailWidth($thumbnailSize)}" data-height="{@$media->getThumbnailHeight($thumbnailSize)}">{if !$removeLinks}</a>{/if}
{else}
<img src="{$mediaLink}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->width}" data-height="{@$media->height}">
{/if}
*/
protected $validBBCodePattern = '~^[a-z](?:[a-z0-9\-_]+)?$~';
+ /**
+ * @var bool
+ * @since 5.2
+ */
+ protected $removeLinks;
+
/**
* @inheritDoc
*/
return $bbcodes;
}
+ /**
+ * @param bool $removeLinks
+ * @since 5.2
+ */
+ public function setRemoveLinks($removeLinks) {
+ $this->removeLinks = $removeLinks;
+ }
+
+ /**
+ * @return bool
+ * @since 5.2
+ */
+ public function getRemoveLinks() {
+ return $this->removeLinks;
+ }
+
/**
* Compiles tag fragments into the custom HTML element.
*
return '';
}
+ $removeLinks = false;
+ if ($parser instanceof HtmlBBCodeParser && $parser->getRemoveLinks()) {
+ $removeLinks = true;
+ }
+
/** @var ViewableMedia $media */
$media = MessageEmbeddedObjectManager::getInstance()->getObject('com.woltlab.wcf.media', $mediaID);
if ($media !== null && $media->isAccessible()) {
+ if ($removeLinks && !$media->isImage) {
+ if ($parser->getOutputType() === 'text/html' || $parser->getOutputType() === 'text/simplified-html') {
+ return StringUtil::encodeHTML($media->getTitle());
+ }
+
+ return StringUtil::encodeHTML($this->getLink($media));
+ }
+
if ($parser->getOutputType() == 'text/html') {
if ($media->isImage) {
$thumbnailSize = (!empty($openingTag['attributes'][1])) ? $openingTag['attributes'][1] : 'original';
return WCF::getTPL()->fetch('mediaBBCodeTag', 'wcf', [
'mediaLink' => $this->getLink($media),
+ 'removeLinks' => $removeLinks,
'thumbnailLink' => $thumbnailSize !== 'original' ? $this->getThumbnailLink($media, $thumbnailSize) : ''
]);
}
*/
protected $outputType = 'text/html';
+ /**
+ * @var bool
+ */
+ protected $removeLinks = false;
+
/**
* @inheritDoc
*/
public function setOutputType($outputType) {
$this->outputType = $outputType;
}
+
+ /**
+ * @param bool $removeLinks
+ * @since 5.2
+ */
+ public function setRemoveLinks($removeLinks) {
+ $this->removeLinks = $removeLinks;
+ }
}
protected function invokeHtmlNode(IHtmlNode $htmlNode) {
/** @var IHtmlOutputNode $htmlNode */
$htmlNode->setOutputType($this->outputType);
+ $htmlNode->setRemoveLinks($this->getHtmlProcessor()->removeLinks);
parent::invokeHtmlNode($htmlNode);
}
public function replaceTag(array $data) {
HtmlBBCodeParser::getInstance()->setOutputType($this->outputType);
- return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes'], $data['element']);
+ if ($this->removeLinks) {
+ HtmlBBCodeParser::getInstance()->setRemoveLinks($this->removeLinks);
+ }
+
+ $output = HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes'], $data['element']);
+
+ if ($this->removeLinks) {
+ HtmlBBCodeParser::getInstance()->setRemoveLinks(false);
+ }
+
+ return $output;
}
}
* @param string $outputType desired output type
*/
public function setOutputType($outputType);
+
+ /**
+ * Requests the HTML output to omit any HTML anchor.
+ *
+ * @param bool $removeLinks
+ * @since 5.2
+ */
+ public function setRemoveLinks($removeLinks);
}