I’m coding a custom theme and I want to link a custom sized thumbnail image to the full size (or large) version of the image.
The code I’m using is:
<?php
$attachment_id = get_field('main_product_photo');
$size = "main-product-thumb"; // (thumbnail, medium, large, full or custom size)
wp_get_attachment_image( $attachment_id, $size );
$image = wp_get_attachment_image_src( $attachment_id, $size );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<a href="<?php echo $image[0]; ?>"><img src="<?php echo $image[0]; ?>"></a>
However, this just links to my thumbnail sized image. Does anyone have a quick fix for this? Thanks!
1 comment