From fc3d9b6890e29ebb3577b2e701b33bb75df39eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AA=E5=AD=90?= Date: Sat, 18 May 2024 18:51:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=87=E7=AB=A0=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E5=BC=A0=E5=9B=BE=E4=BD=9C=E4=B8=BAcover?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 10 +++++++++- postlist.php | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 1347a5e..3542d1b 100644 --- a/functions.php +++ b/functions.php @@ -155,4 +155,12 @@ function allwords() { echo '全站共 '.$chars.' 字,写完一本我国著名的四大名著了!';} elseif ($chars>1000000){ echo '全站共 '.$chars.' 字,已写一本列夫·托尔斯泰的《战争与和平》了!';} -} \ No newline at end of file +} +function show_first_image($content) { + preg_match_all('//i', $content, $matches); + // 检查是否找到了图片 + if(isset($matches[1][0])){ + return $matches[1][0]; + } + return false; // 没有找到图片,返回 false +} \ No newline at end of file diff --git a/postlist.php b/postlist.php index b8567ff..fde3c59 100644 --- a/postlist.php +++ b/postlist.php @@ -55,7 +55,11 @@ commentsNum('评论', '1 评论', '%d 评论'); ?> - + + content); ?> + + 文章图片 +