WP_Widget_Media_Gallery::render_media() WordPress Method

The WP_Widget_Media_Gallery::render_media() method is used to display a gallery of images in a WordPress widget. This method accepts two arguments: an array of image objects and a boolean value indicating whether to display the gallery in a lightbox. The gallery will be displayed in a grid of thumbnails. If the lightbox argument is set to true, clicking on a thumbnail will open the image in a lightbox. Otherwise, clicking on a thumbnail will take the user to the full-size image. The WP_Widget_Media_Gallery::render_media() method is a convenient way to display a gallery of images in a WordPress widget.

WP_Widget_Media_Gallery::render_media( array $instance ) #

Render the media on the frontend.


Parameters

$instance

(array)(Required)Widget instance props.


Top ↑

Source

File: wp-includes/widgets/class-wp-widget-media-gallery.php

	public function render_media( $instance ) {
		$instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' ), $instance );

		$shortcode_atts = array_merge(
			$instance,
			array(
				'link' => $instance['link_type'],
			)
		);

		// @codeCoverageIgnoreStart
		if ( $instance['orderby_random'] ) {
			$shortcode_atts['orderby'] = 'rand';
		}

		// @codeCoverageIgnoreEnd
		echo gallery_shortcode( $shortcode_atts );
	}


Top ↑

Changelog

Changelog
VersionDescription
4.9.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.