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.
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 );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 4.9.0 | Introduced. |