Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GeneratePress - WOO Stacked Image Gallery for Single Product
<div class="woo-sumamry-wrap"><!-- open wrap -->
<div class="woo-gallery-stack hide-on-mobile">
<?php
global $product;
// Get post product thumbnail
if ( has_post_thumbnail( $product->get_id() ) ) {
$attachment_ids[0] = get_post_thumbnail_id( $product->get_id() );
$attachment = wp_get_attachment_image_src( $attachment_ids[0], 'full' );
$attachment_alt = get_post_meta( $attachment_ids[0], '_wp_attachment_image_alt', TRUE);
$attachmnent_title = get_the_title( $attachment_ids[0] );
?>
<img src="<?php echo $attachment[0] ; ?>" alt="<?php echo $attachment_alt; ?>" title="<?php echo $attachmnent_title; ?>" />
<?php
}
// Get Product Gallery Images
if ( method_exists( $product, 'get_gallery_image_ids' ) ) {
$product_image_ids = $product->get_gallery_image_ids();
foreach( $product_image_ids as $product_image_id ) {
$image_url = wp_get_attachment_url( $product_image_id, 'full' );
$image_alt = get_post_meta( $product_image_id, '_wp_attachment_image_alt', TRUE);
$image_title = get_the_title( $product_image_id );
echo '<img src="' . $image_url . '" alt="' . $image_alt . '" title="' . $image_title . '">';
}
}
// Closing div found in Close Summary Wrap element
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.