From 8aec57b257017ed9062bbc9d6c0d181c79f8cd9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Sun, 16 Mar 2025 16:16:57 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=BF=87=E6=BB=A4svg=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/functions.php b/functions.php index 0a2a30c..1806ea7 100644 --- a/functions.php +++ b/functions.php @@ -133,7 +133,6 @@ function getPermalinkFromCoid($coid) { if (empty($row)) return ''; return '@'.$row['author'].''; } - /** * 图片灯箱 */ @@ -166,8 +165,8 @@ class ImageStructureProcessor { $xpath = new DOMXPath($dom); - // 查找所有没有父 figure 的图片 - $images = $xpath->query("//img[not(ancestor::figure)]"); + // 查找所有没有父 figure 的图片,排除SVG + $images = $xpath->query("//img[not(ancestor::figure) and not(contains(@src, '.svg'))]"); if ($images->length > 0) { foreach ($images as $img) { @@ -175,8 +174,9 @@ class ImageStructureProcessor { $src = $img->getAttribute('src'); $alt = $img->getAttribute('alt'); - if (empty($src)) { - continue; // 跳过没有 src 的图片 + // 跳过没有src的图片或SVG格式的图片 + if (empty($src) || stripos($src, '.svg') !== false) { + continue; } // 创建容器元素