获取文章第一张图作为cover

This commit is contained in:
浪子
2024-05-18 18:51:07 +08:00
parent d8cf19ca6d
commit fc3d9b6890
2 changed files with 14 additions and 2 deletions
+5 -1
View File
@@ -55,7 +55,11 @@
</svg>
<a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('评论', '1 评论', '%d 评论'); ?></a>
</div>
</div>
</div>
<?php $firstImage = show_first_image($this->content); ?>
<?php if($firstImage): ?>
<img src="<?php echo $firstImage; ?>" alt="文章图片" class="cover"/>
<?php endif; ?>
</article>
<?php endwhile; ?>