The Gallery shortcode.

This implements the functionality of the Gallery Shortcode for displaying WordPress images on a post.

Signature

gallery_shortcode( $attr )
attr
 (array) Attributes of the gallery shortcode.

Return

(string) HTML content to display gallery.

Source

function gallery_shortcode( $attr ) {
	$post = get_post();

	static $instance = 0;
	$instance++;

	if ( ! empty( $attr['ids'] ) ) {
		// 'ids' is explicitly ordered, unless you specify otherwise.
		if ( empty( $attr['orderby'] ) )
			$attr['orderby'] = 'post__in';
		$attr['include'] = $attr['ids'];
	}

	/**
	 * Filter the default gallery shortcode output.
	 *
	 * If the filtered output isn't empty, it will be used instead of generating
	 * the default gallery template.
	 *
	 * @since 2.5.0
164 more lines...
WP Trac GitHub

Link here