From e8819fc636f94e3c5b64a7142e1dc4254cd2d315 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Wed, 26 Feb 2014 22:20:31 +0000 Subject: [PATCH] Introduce HTML5 gallery support. When a theme supports HTML5 galleries via add_theme_support( 'html5', 'gallery' ), figure and figcaption will be used instead of definition list markup. props obenland. fixes #26697. Built from https://develop.svn.wordpress.org/trunk@27302 git-svn-id: http://core.svn.wordpress.org/trunk@27155 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index ebcfa0e387..62c124aaa9 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -762,9 +762,12 @@ add_shortcode('gallery', 'gallery_shortcode'); * @type string $orderby The field to use when ordering the images. Default 'menu_order ID'. * Accepts any valid SQL ORDERBY statement. * @type int $id Post ID. - * @type string $itemtag HTML tag to use for each image in the gallery. Default 'dl'. - * @type string $icontag HTML tag to use for each image's icon. Default 'dt'. - * @type string $captiontag HTML tag to use for each image's caption. Default 'dd'. + * @type string $itemtag HTML tag to use for each image in the gallery. + * Default 'dl', or 'figure' when the theme registers HTML5 gallery support. + * @type string $icontag HTML tag to use for each image's icon. + * Default 'dt', or 'div' when the theme registers HTML5 gallery support. + * @type string $captiontag HTML tag to use for each image's caption. + * Default 'dd', or 'figcaption' when the theme registers HTML5 gallery support. * @type int $columns Number of columns of images to display. Default 3. * @type string $size Size of the images to display. Default 'thumbnail'. * @type string $ids A comma-separated list of IDs of attachments to display. Default empty. @@ -812,13 +815,14 @@ function gallery_shortcode( $attr ) { unset( $attr['orderby'] ); } + $html5 = current_theme_supports( 'html5', 'gallery' ); extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, - 'itemtag' => 'dl', - 'icontag' => 'dt', - 'captiontag' => 'dd', + 'itemtag' => $html5 ? 'figure' : 'dl', + 'icontag' => $html5 ? 'div' : 'dt', + 'captiontag' => $html5 ? 'figcaption' : 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '',