@@ -105,7 +105,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b
105
105
* See https://github.com/WordPress/wordpress-develop/blob/3f9c6fce666ed2ea0d56c21f6235c37db3d91392/src/wp-includes/blocks/post-featured-image.php#L65
106
106
*/
107
107
if ( 'core/post-featured-image ' === $ block ->name && isset ( $ block ->context ['postId ' ] ) ) {
108
- $ id = auto_sizes_get_featured_image_id_from_block ( $ block );
108
+ $ id = auto_sizes_get_featured_image_id_from_block ( $ block-> context [ ' postId ' ] );
109
109
}
110
110
111
111
/*
@@ -133,7 +133,7 @@ function auto_sizes_filter_image_tag( $content, array $parsed_block, WP_Block $b
133
133
* See https://github.com/WordPress/wordpress-develop/blob/3f9c6fce666ed2ea0d56c21f6235c37db3d91392/src/wp-includes/blocks/post-featured-image.php#L65
134
134
*/
135
135
if ( 'core/post-featured-image ' === $ block ->name && isset ( $ block ->context ['postId ' ] ) ) {
136
- $ id = auto_sizes_get_featured_image_id_from_block ( $ block );
136
+ $ id = auto_sizes_get_featured_image_id_from_block ( $ block-> context [ ' postId ' ] );
137
137
}
138
138
139
139
$ sizes = wp_calculate_image_sizes (
@@ -386,17 +386,13 @@ function auto_sizes_filter_render_block_context( array $context, array $block, ?
386
386
*
387
387
* @since n.e.x.t
388
388
*
389
- * @param WP_Block $block The block instance .
389
+ * @param int $post_id The post id .
390
390
* @return int The featured image ID or 0 if not found.
391
391
*/
392
- function auto_sizes_get_featured_image_id_from_block ( WP_Block $ block ): int {
393
- $ post_id = $ block ->context ['postId ' ];
394
-
395
- $ post = get_post ( $ post_id );
396
-
397
- if ( ! ( $ post instanceof WP_Post ) ) {
392
+ function auto_sizes_get_featured_image_id_from_block ( int $ post_id ): int {
393
+ if ( 0 === $ post_id ) {
398
394
return 0 ;
399
395
}
400
396
401
- return (int ) get_post_thumbnail_id ( $ post );
397
+ return (int ) get_post_thumbnail_id ( $ post_id );
402
398
}
0 commit comments