fix(renderer): render [attach=xx] as <img> for image attachments (legacy sablog behavior)
This commit is contained in:
@@ -137,7 +137,9 @@ class PostContentRenderer
|
||||
continue;
|
||||
}
|
||||
|
||||
$replacement = $type === 'img'
|
||||
// 老 sablog 的 [attach=xx] 对图片附件就是直接贴图,mime 是图片时用 <img>
|
||||
$isImage = str_starts_with((string) $media->mime_type, 'image/');
|
||||
$replacement = $type === 'img' || $isImage
|
||||
? sprintf('<img src="%s" alt="%s" loading="lazy" />', $media->getUrl(), e($media->name))
|
||||
: sprintf('<a href="%s">%s</a>', $media->getUrl(), e($media->file_name));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user