Compare commits
2 commits
b4f5dd0660
...
adb80bad9e
Author | SHA1 | Date | |
---|---|---|---|
adb80bad9e | |||
f30cf41f86 |
2 changed files with 15 additions and 3 deletions
|
@ -79,6 +79,11 @@ const $e = function(info, attrs, child, created) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'boolean':
|
||||||
|
if(attr)
|
||||||
|
elem.setAttribute(key, '');
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(key === 'className')
|
if(key === 'className')
|
||||||
key = 'class';
|
key = 'class';
|
||||||
|
|
|
@ -5,8 +5,11 @@ use Misuzu\Parsers\BBCode\BBCodeTag;
|
||||||
|
|
||||||
final class ImageTag extends BBCodeTag {
|
final class ImageTag extends BBCodeTag {
|
||||||
public function parseText(string $text): string {
|
public function parseText(string $text): string {
|
||||||
return preg_replace_callback("/\[img\]((?:https?:)?\/\/.+?)\[\/img\]/", function ($matches) {
|
return preg_replace_callback("/\[(img|imgmap)\]((?:https?:)?\/\/.+?)\[\/(img|imgmap)\]/", function($matches) {
|
||||||
$url = parse_url($matches[1]);
|
if($matches[1] !== $matches[3])
|
||||||
|
return $matches[0];
|
||||||
|
|
||||||
|
$url = parse_url($matches[2]);
|
||||||
|
|
||||||
if(!empty($url['scheme']) && !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
|
if(!empty($url['scheme']) && !in_array(mb_strtolower($url['scheme']), ['http', 'https'], true))
|
||||||
return $matches[0];
|
return $matches[0];
|
||||||
|
@ -17,7 +20,11 @@ final class ImageTag extends BBCodeTag {
|
||||||
// $matches[1]
|
// $matches[1]
|
||||||
// );
|
// );
|
||||||
|
|
||||||
return sprintf('<img src="%1$s" alt="%1$s" style="max-width:100%%;max-height:900px;">', $matches[1]);
|
return sprintf(
|
||||||
|
'<img src="%1$s" alt="%1$s" style="max-width:100%%;max-height:900px;"%2$s>',
|
||||||
|
$matches[2],
|
||||||
|
$matches[1] === 'imgmap' ? ' ismap' : '',
|
||||||
|
);
|
||||||
}, $text);
|
}, $text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue