Skip to content

Commit d33874f

Browse files
kniceclaude
andcommitted
fix: ensure image_meta is always an array in Featured_News_Block_Controller
wp_get_attachment_metadata() can return false when no metadata exists, which would cause errors downstream. Added type guard to default to an empty array. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f825c96 commit d33874f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/Components/Featured_News_Block_Controller.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ protected function prepare_posts_for_display( array $posts = [], bool $is_auto_q
3030
}
3131
$image_id = get_post_thumbnail_id( $post_id );
3232
$image_meta = $image_id > 0 ? wp_get_attachment_metadata( $image_id ) : [];
33+
$image_meta = is_array( $image_meta ) ? $image_meta : [];
3334
$image_url = wp_get_attachment_url( $image_id );
3435
$taxonomy = $this->query_loop[ Query_Loop::QUERY_LOOP ][ Taxonomies::TAXONOMIES ] ?: 'category';
3536
$category = $this->get_primary_term( $post_id, $taxonomy );

0 commit comments

Comments
 (0)