Skip to content

Commit

Permalink
fix: Add check for WP_Post
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Aug 30, 2024
1 parent 98fca17 commit 37c2176
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Timmy.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public static function get_image( $attachment, $size ) {
$attachment = (int) $attachment['ID'];
}

// Check if we work with a WordPress post. This doesn’t necessarily have
// to be an attachment, that’s why we don’t check for the 'attachment'
// post type.
$wp_post = \get_post( $attachment );

if ( ! $wp_post ) {
return null;
}

$class = apply_filters( 'timmy/image/class', Image::class );
$size_array = $size;

Expand Down

0 comments on commit 37c2176

Please sign in to comment.