Categories
Uncategorized

ACF: Declaring what image size to use

<?php
    $attachment_id = get_field('image');
    $size = "medium";
    $size2 = "large";
    $image = wp_get_attachment_image_src( $attachment_id, $size );
    $image2 = wp_get_attachment_image_src( $attachment_id, $size2 );
    $alt_text = get_post_meta($attachment_id , '_wp_attachment_image_alt', true);
?>
<a href="<?php echo $image2[0];"><img src="<?php echo $image[0]; ?>" alt="<?php echo $alt_text; ?>" /></a>

You must set the image return type to ‘ID’.
Change “get_field” to “get_sub_field” if using  repeater.