This function was created for use with the “gallery” post format. Its purpose is to return the number of items displayed in the post’s gallery or galleries. It is similar to the function hybrid_get_gallery_image_count(), except that it counts attachments other than images. The reason for this is because scripts like Cleaner Gallery allow galleries to use other types of media.
This function accepts no parameters.
This function will return the number of items used in galleries in the post if any are found. Otherwise, it will return the number of media items 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 items in a text string.
<?php $count = hybrid_get_gallery_item_count(); ?> <p class="image-count"> <?php printf( _n( 'This gallery contains %s item.', 'This gallery contains %s items.', $count, 'chun' ), $count ); ?> </p>