Home Forums Add-ons Repeater Field Repeater / Image Size Issue


Repeater / Image Size Issue

  • Hi,

    I am trying to show an image at a certain size within a repeater field which then loads within Fancybox upon click.
    I can get the image to load but not at the custom size. I am not sure where I am going wrong. Please could someone give me some advice.

    The URL is here:

    Note: When I uncomment the first 3 lines, it breaks the image totally. Nothing shows.

    My code:`



  • Hi @huwrowlands

    Your commented code at the top suggests that you understand how to get a variabel (attachment ID) and then load a url from it.

    Why then, are you just echoing the ID into the img and a elements?

  • I ended up using this code that works great:

    $attachment_id = get_sub_field('gallery_image');
    $size_thumb = "gallery-img"; // (thumbnail, medium, large, full or custom size)
    $size_gallery = "full"; // (thumbnail, medium, large, full or custom size)
    $image_thumb = wp_get_attachment_image_src( $attachment_id, $size_thumb );
    $image_gallery = wp_get_attachment_image_src( $attachment_id, $size_gallery );
    	// url = $image[0];
    	// width = $image[1];
    	// height = $image[2]; ?>
    <div class="gallery-img">	
     <img alt="Dance Avenue" src="<?php echo $image_thumb[0]; ?>" />
      <div class="enlarge-img">
        echo '<a class="fancybox" rel="group-'.get_the_ID().'" href="';
        echo $image_gallery[0];
        echo '">View Images</a>';
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Repeater / Image Size Issue’ is closed to new replies.