Support

Account

Home Forums Add-ons Repeater Field Repeater does not output images

Solving

Repeater does not output images

  • I am using repeater plugin with this code for simple gallery:

    <?php if( have_rows('gallery') ): ?>
    <ul class="slides">								 
    <?php while( have_rows('gallery') ):
    the_row(); 						 
    										// vars
    										$image = get_sub_field('slider_images');							 
    										?>	
    										<li
    class="slide">		 							 
    <img src="<?php echo $image['url']; ?>" alt=""
    />								 							 								 
    										</li>								 
    <?php endwhile; ?>								 
    									</ul>								 
    <?php endif; ?>

    And this is html output:

    <ul class="slides">								 	<li class="slide">								 	<img alt="" src="">								 											</li>								 
    								 
    </ul>

    Apologies for messy code, this editor is behaving weirdly.

    The image is empty, I have double checked and the sub_field “slider_images” is set to be Image URL.
    I copied the code from documentation,
    What is wrong?

  • If the field is set to ‘URL’ then just use:

    <img src="<?php echo $image; ?>" alt="" />

    or:

    <img src="<?php the_sub_field('slider_images'); ?>" alt="" />

    Your original code:

    <img src="<?php echo $image['url']; ?>" alt="" />

    refers to the ‘image object’ which your not using.

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

The topic ‘Repeater does not output images’ is closed to new replies.