<span class="mediaBBCode{if $float != 'none'} messageFloatObject{$float|ucfirst}{/if}">
{if $thumbnailSize != 'original'}
- <a href="{$media->getLink()}" class="embeddedAttachmentLink jsImageViewer"><img src="{$media->getThumbnailLink($thumbnailSize)}" alt="{$media->altText}" title="{$media->title}"></a>
+ <a href="{$media->getLink()}" class="embeddedAttachmentLink jsImageViewer"><img src="{$media->getThumbnailLink($thumbnailSize)}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->getThumbnailWidth($thumbnailSize)}" data-height="{@$media->getThumbnailHeight($thumbnailSize)}"></a>
{else}
- <img src="{$media->getLink()}" alt="{$media->altText}" title="{$media->title}">
+ <img src="{$media->getLink()}" alt="{$media->altText}" title="{$media->title}" data-width="{@$media->width}" data-height="{@$media->height}">
{/if}
-
+
{if $media->caption}
<span class="mediaBBCodeCaption">{$media->caption}</span>
{/if}
public function getHtml() {
$html = $this->getHtmlOutputNodeProcessor()->getHtml();
- $html = str_ireplace('<img', '<amp-img layout="flex-item"', $html);
+ $html = preg_replace_callback('/<img([^>]+)>/i', function($match) {
+ $attributes = str_replace('data-width="', 'width="', $match[1]);
+ $attributes = str_replace('data-height="', 'height="', $attributes);
+ return '<amp-img layout="flex-item"'.$attributes.'>';
+ }, $html);
+
$html = str_ireplace('<iframe', '<amp-iframe layout="responsive" width="480" height="300" sizes="(min-width: 480px) 480px, 100vw" ', $html);
$html = str_ireplace('</iframe>', '<div class="wscIframePlaceholder" placeholder=""></div></amp-iframe>', $html);