Support

Account

Home Forums Add-ons Repeater Field Repeater, image field custom gallery

Helping

Repeater, image field custom gallery

  • I am trying to make custom gallery with repetar field. Idea is basic, to have thumbnail of proper size and image in different hi res size. lets say that i want thumb 100×100 and hi res image to be 1024xXXXX.

    Code i use is this one :

    
    <?php if( have_rows('photo_thumbnails') ): ?>
    
      <?php while( have_rows('photo_thumbnails') ): the_row(); 
    
        $attachment_id = get_sub_field('gallery_image_10');
        $size = "photoThumb"; // (thumbnail, medium, large, full or custom size)
        $image = wp_get_attachment_image_src( $attachment_id, $size );
    
        ?>
                            <div class="col-md-3 col-sm-6">
                                <div class="item">
                                    <div class="view view-first">
                                        <img class="img-responsive" alt="" src="<?php echo $image[0]; ?>" />
                                        <div class="mask-loupe wrapper-parent">
                                            <a href="<?php the_sub_field('hi_res_image_10'); ?>" class="play-box" title="<?php the_sub_field('image_caption'); ?>">sve</a>
                                        </div>
                                    </div>
                                </div><!-- // item -->  
                            </div>
      
    
      <?php endwhile; ?>
    <?php endif; ?>
    

    But i dont like this approach for hi-res (blow up) image , because it does not resize it. It use even if i put 5000×5000 image and thats bad. So how can i make custom size for that part also? Since for thumbnail i use this

        $attachment_id = get_sub_field('gallery_image_10');
        $size = "photoThumb"; // (thumbnail, medium, large, full or custom size)
        $image = wp_get_attachment_image_src( $attachment_id, $size );
    
    <img class="img-responsive" alt="" src="<?php echo $image[0]; ?>" />
    

    And that works perfect. But i want to use same stuff under

    <a href="<?php the_sub_field('hi_res_image_10'); ?>" class="play-box" title="<?php the_sub_field('image_caption'); ?>">sve</a>
    

    Thanks!

  • Hi @mitrovics

    It seems you code is doesn’t doesn’t have the img tag and thus it doesn’t show any images.

    If you want the anchor to link to the page, I would recommend that you test the image value to ensure that the image field returns a link and not an ID.

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Repeater, image field custom gallery’ is closed to new replies.