cid, ""); $autoThumbnailCategories = array('探店', '爸爸厨房', '户外'); // 需要自动获取封面的分类 // 获取当前文章的分类 $categories = $this->categories; $currentCategory = ''; if (!empty($categories)) { $currentCategory = $categories[0]['name']; } // 封面显示逻辑 $showThumbnail = false; if ($thumbnail) { // 如果有手动设置的封面,始终显示 $showThumbnail = true; } elseif (in_array($currentCategory, $autoThumbnailCategories)) { // 如果是指定分类且没有设置封面,从文章内容中提取第一张图片 preg_match_all('/content, $matches); if (!empty($matches[1])) { $thumbnail = $matches[1][0]; $showThumbnail = true; } } if ($showThumbnail && $thumbnail): ?> <?php $this->title(); ?>
author() ?> category("·", true, "无"); ?> created);?>

fields->description; if (!empty($customDescription)) { // 如果有自定义描述,直接显示 echo Typecho_Common::subStr(strip_tags($customDescription), 0, 100, '...'); } else { // 如果没有自定义描述,使用原有的excerpt方法 $this->excerpt(100, ""); } ?>