Skip to content

Commit

Permalink
Fix: avoid exception if thumbnail image is not found (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
albig authored Dec 2, 2024
1 parent 8d5ed79 commit 4690778
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ function sunflower_the_social_media_sharers() {
* element when on single views.
*
* @param boolean $styled_layout Is this a styled layout.
* @param boolean $caption Show the caption.
* @param boolean $show_caption Show the caption.
* @param boolean $is_block Is latest news block.
*/
function sunflower_post_thumbnail( $styled_layout = false, $caption = false, $is_block = false ) {
function sunflower_post_thumbnail( $styled_layout = false, $show_caption = false, $is_block = false ) {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
Expand All @@ -183,8 +183,8 @@ function sunflower_post_thumbnail( $styled_layout = false, $caption = false, $is
?>

<?php
if ( $caption ) {
$caption = get_post( get_post_thumbnail_id() )->post_excerpt;
if ( $show_caption ) {
$caption = get_post( get_post_thumbnail_id() )?->post_excerpt;
if ( ! empty( $caption ) ) {
?>
<figcaption><?php echo esc_attr( $caption ); ?></figcaption>
Expand Down

0 comments on commit 4690778

Please sign in to comment.