Account Settings

Winkelwagen

De winkelwagen is nog leeg

Website Settings

Dondere modus
Hoog contrast
Font grootte
Lees pagina-inhoud
Afdrukken
Realtime
  • Datum: 19-02-2026
  • Week: 08
  • Weer:
  • Seizoen: Winter

single-product/product-image.php

Bekijk website

Omschrijving

The single-product/product-image.php template in WooCommerce is a core component that handles the display of product images on single product pages. This template is primarily responsible for showcasing the main product image and any additional gallery images that the product may have. It’s a crucial part of the product detail page as it helps customers visually assess the product before making a purchase.

Key Features of single-product/product-image.php

  1. Image Gallery Integration: This template includes functionality to display a main image and a series of thumbnails if the product has multiple images. This setup is typically powered by a combination of CSS for layout and JavaScript for interactive elements like sliders or lightboxes.
  2. Responsive and Interactive: The image display is responsive, meaning it adjusts to fit different screen sizes and devices. It often includes zoom features or lightbox functionalities to enhance user interaction and viewability.
  3. WCAG Compliance: Attention is generally given to accessibility, ensuring that image galleries are navigable with keyboard shortcuts and are screen-reader friendly, aligning with WCAG (Web Content Accessibility Guidelines).

Default Structure

In its simplest form, the product-image.php template might look something like this:

phpCode kopiërenif ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $post, $product;

$columns           = apply_filters( 'woocommerce_product_thumbnails_columns', 4 );
$post_thumbnail_id = $product->get_image_id();
$wrapper_classes   = apply_filters( 'woocommerce_single_product_image_gallery_classes', array(
	'woocommerce-product-gallery',
	'woocommerce-product-gallery--' . ($post_thumbnail_id ? 'with-images' : 'without-images'),
	'woocommerce-product-gallery--columns-' . absint( $columns ),
	'images',
) );
?>
<div class="<?php echo esc_attr( implode( ' ', $wrapper_classes ) ); ?>">
	<figure class="woocommerce-product-gallery__wrapper">
		<?php
		if ( $post_thumbnail_id ) {
			$html = wc_get_gallery_image_html( $post_thumbnail_id, true );
		} else {
			$html  = '<div class="woocommerce-product-gallery__image--placeholder">';
			$html .= sprintf( '<img src="%s" alt="%s" />', esc_url( wc_placeholder_img_src() ), esc_html__( 'Awaiting product image', 'woocommerce' ) );
			$html .= '</div>';
		}

		echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $post_thumbnail_id );

		do_action( 'woocommerce_product_thumbnails' );
		?>
	</figure>
</div>

Customizing the Template

  1. Override the Template: To customize this template, you can copy it from plugins/woocommerce/templates/single-product/product-image.php to yourtheme/woocommerce/single-product/product-image.php and make your modifications.
  2. Add Custom Functionality: Developers often add features like image zoom, sliders, or integrate third-party libraries for more interactive image galleries.
  3. Styling Adjustments: Through CSS, you can modify how the images and thumbnails are displayed, change layout configurations, or add animations.
  4. Accessibility Enhancements: Adding aria-labels, roles, or improving keyboard navigation can make the gallery more accessible.

Conclusion

The single-product/product-image.php template is vital for providing potential customers with a clear and detailed view of products. Effective use of this template can significantly enhance the user experience on a WooCommerce site by making products more attractive and easier to evaluate. Customizing this template allows store owners to differentiate their product presentations and potentially increase conversion rates through improved visual engagement.

Relations

ItemType

Pointing items

ItemTypeCategoryTags

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *

Home