wc_get_product_gallery_html()
Get HTML for a complete product gallery.
Delegates to the single-product/product-image.php template so themes that override that template are honored, and so any extensions hooked on woocommerce_product_thumbnails woocommerce_single_product_image_thumbnail_html fire on variation gallery swaps.
No Hooks.
Returns
String.
Usage
wc_get_product_gallery_html( $product, $image_ids );
- $product(WC_Product) (required)
- Product used for gallery context.
- $image_ids(array|null)
- Ordered image IDs to render. When null, the template renders the product's own featured image and gallery; otherwise the supplied IDs are presented to the template as if they were the product's own images (the first ID becomes the featured slot, the rest the gallery).
Default:null
Changelog
| Since 10.8.0 | Introduced. |
wc_get_product_gallery_html() wc get product gallery html code WC 10.9.1
function wc_get_product_gallery_html( $product, $image_ids = null ) {
if ( ! $product instanceof WC_Product ) {
return '';
}
if ( null === $image_ids ) {
return wc_render_product_image_template_for( $product );
}
return wc_render_product_image_template_for_image_ids( $product, $image_ids );
}