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); ?> + + 文章图片 +