24 lines
892 B
PHP
24 lines
892 B
PHP
<?php
|
|
namespace Misuzu\Parsers\BBCode\Tags;
|
|
|
|
use Misuzu\Parsers\BBCode\BBCodeTag;
|
|
|
|
final class ImageTag extends BBCodeTag {
|
|
public function parseText(string $text): string {
|
|
return preg_replace_callback("/\[img\]((?:https?:\/\/).+?)\[\/img\]/", function ($matches) {
|
|
$url = parse_url($matches[1]);
|
|
|
|
if(empty($url['scheme']) || !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
|
|
return $matches[0];
|
|
|
|
// return sprintf(
|
|
// '<span class="js-msz-embed-media" data-msz-embed-url="%1$s"></span>'
|
|
// . '<noscript><img src="%1$s" alt="%1$s" style="max-width:100%%;max-height:900px;"></noscript>',
|
|
// $matches[1]
|
|
// );
|
|
|
|
return sprintf('<img src="%1$s" alt="%1$s" style="max-width:100%%;max-height:900px;">', $matches[1]);
|
|
}, $text);
|
|
}
|
|
}
|