This function was created for use with the “gallery” post format. Its purpose is to return the number of images displayed in the post’s gallery or galleries.
This function accepts no parameters.
This function will return the number of images used in galleries in the post if any are found. Otherwise, it will return the number of images attached to the post.
Since this function can return a 0, 1, or a larger number, you’ll want to make sure to account for that when outputting the text and with translations. That’s where the WordPress _n() function comes in handy, which will handle single or plural forms depending on the count.
The following will display the number of images in a text string.
<?php $count = hybrid_get_gallery_image_count(); ?> <p class="image-count"> <?php printf( _n( 'This gallery contains %s image.', 'This gallery contains %s images.', $count, 'chun' ), $count ); ?> </p>