get_post_gallery_images() WordPress Function

The get_post_gallery_images() function allows you to retrieve the images from a gallery post.

get_post_gallery_images( int|WP_Post $post ) #

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


Description

Top ↑

See also


Top ↑

Parameters

$post

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


Top ↑

Return

(string[]) A list of a gallery's image srcs in order.


Top ↑

Source

File: wp-includes/media.php

function get_post_gallery_images( $post = 0 ) {
	$gallery = get_post_gallery( $post, false );
	return empty( $gallery['src'] ) ? array() : $gallery['src'];
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More