get_post_gallery_images

Checks a post's content for galleries and return the image srcs for the first found gallery.

Description

(array) get_post_gallery_images( (int) $post = 0 ); 

Returns (array)

A list of a gallery's image srcs in order.

Parameters (1)

0. $post — Optional. (int)
Post ID or WP_Post object. Default is global $post..

Usage

  1. if ( !function_exists( 'get_post_gallery_images' ) ) { 
  2. require_once ABSPATH . WPINC . '/media.php'; 
  3.  
  4. // Optional. Post ID or WP_Post object. Default is global `$post`. 
  5. $post = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_post_gallery_images($post); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/media.php  
  1. function get_post_gallery_images( $post = 0 ) { 
  2. $gallery = get_post_gallery( $post, false ); 
  3. return empty( $gallery['src'] ) ? array() : $gallery['src'];