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


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') ):
    										// vars
    										$image = get_sub_field('slider_images');							 
    <img src="<?php echo $image['url']; ?>" alt=""
    <?php endwhile; ?>								 
    <?php endif; ?>

    And this is html output:

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

    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="" />


    <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.