George Pennet George Pennet - 4 years ago 151
PHP Question

Wocommerce full size img with large - product-image.php

I want to replace full size image with large image on woocommerce lighbox.

here is my code -

<?php
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
$image_title = esc_attr( get_the_title( get_post_thumbnail_id() ) );
$image_link = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID) );
$attachment_count = count( $product->get_gallery_attachment_ids() );

if ( $attachment_count > 0 ) {
$gallery = '[product-gallery]';
} else {
$gallery = '';
}
echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<a href="%s" itemprop="image" class="bigbox woocommerce-main-image zoom" title="%s" rel="prettyPhoto' . $gallery . '">%s</a>', $image_link, $image_title, $image ), $post->ID );

} else {

echo apply_filters( 'woocommerce_single_product_image_html', sprintf( '<img src="%s" alt="Placeholder" class="bigbox" />', woocommerce_placeholder_img_src() ), $post->ID );

}
?>

<?php do_action( 'woocommerce_product_thumbnails' ); ?>


I've tried to change $image_link to

$image_link = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );


with no luck.

Answer Source

The $image_link comes as array. to echo the image link, try,

<?php echo $image_link[0]; ?> So your full code should be like this

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download