get_post_gallery_images( int|WP_Post $post ): string[]
Checks a post’s content for galleries and return the image srcs for the first found gallery.
Description
See also
Parameters
Return
string[] A list of a gallery's image srcs in order.
Source
File: wp-includes/media.php
.
View all references
function get_post_gallery_images( $post = 0 ) {
$gallery = get_post_gallery( $post, false );
return empty( $gallery['src'] ) ? array() : $gallery['src'];
}
Changelog
Version | Description |
---|---|
3.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Example
A simple example of how to append the raw image URLs to the content of any post or page that has at least one gallery.
This does not work if the gallery type is set to ‘slideshow’. It returns nothing. Removing type=”slideshow” from the gallery shortcode allows the images to be picked up by this function.