This commit is contained in:
浪子
2024-06-06 11:56:02 +08:00
parent 6473985801
commit dc59ba972e
3 changed files with 25 additions and 20 deletions
+5 -9
View File
@@ -57,16 +57,12 @@
</div>
</div>
<?php
// 从文章内容中提取第一张图片
$firstImage = show_first_image($this->content);
// 检查自定义字段cover是否已设置
$cover = $this->fields->cover;
// 如果自定义字段cover已设置,则优先使用
// 如果没有设置,则显示文章的第一张图片
$imageToDisplay = !empty($cover) ? $cover : $firstImage;
if($imageToDisplay): ?>
$firstImage = img_postthumb($this->cid);
$cover = $this->fields->cover;
$imageToDisplay = !empty($cover) ? $cover : $firstImage;
if($imageToDisplay): ?>
<img src="<?php echo $imageToDisplay; ?>" alt="文章图片" class="cover"/>
<?php endif; ?>
<?php endif; ?>
</article>
<?php endwhile; ?>
<?php