re-added max_images check

props @mexon
This commit is contained in:
Matthias Pfefferle 2023-01-12 22:21:48 +01:00
parent 6992fbbe22
commit c06a7d44cf

View file

@ -88,11 +88,14 @@ class Post {
$id = $this->post->ID; $id = $this->post->ID;
$image_ids = array(); $image_ids = array();
// list post thumbnail first if this post has one // list post thumbnail first if this post has one
if ( \function_exists( 'has_post_thumbnail' ) && \has_post_thumbnail( $id ) ) { if ( \function_exists( 'has_post_thumbnail' ) && \has_post_thumbnail( $id ) ) {
$image_ids[] = \get_post_thumbnail_id( $id ); $image_ids[] = \get_post_thumbnail_id( $id );
$max_images--; $max_images--;
} }
if ( $max_images > 0 ) {
// then list any image attachments // then list any image attachments
$query = new \WP_Query( $query = new \WP_Query(
array( array(
@ -110,6 +113,7 @@ class Post {
$image_ids[] = $attachment->ID; $image_ids[] = $attachment->ID;
} }
} }
}
$image_ids = \array_unique( $image_ids ); $image_ids = \array_unique( $image_ids );