Support

Account

Home Forums Add-ons Repeater Field Image paths broken (repeater field)

Solved

Image paths broken (repeater field)

  • Hi there,

    I’m trying to add in up to three repeater rows in a template.

    The repeater field is called – sponsor_logo and the sub-fields are 1) sponsor_logos (image) and 2) sponsor_link (URL).

    I have the following code running in my template:

    <?php if( have_rows('sponsor_logo') ): ?>
    			<?php while ( have_rows('sponsor_logo') ) : the_row(); ?>
    			
    					<a href="<?php the_sub_field('sponsor_link'); ?>" target="_new">
    						<img src="<?php the_sub_field('sponsor_logos'); ?>" alt="sponsor-image" class="sponsor-image" />
    					</a>
    				
    			<?php endwhile; ?>
    			<?php endif; ?>
    

    I can get all to display, apart from the image itself – the paths seem to not be registering correctly – a Firebug inspection of the broken image suggests an attempted path of:

    <img src="392, 392, dummy-logo1, dummy-logo1.jpg, http://mysite/wp-content/uploads/2015/08/dummy-logo1.jpg, , 1, , , dummy-logo1, 2015-08-13 10:17:46, 2015-08-13 10:17:46, image/jpeg, image, http://mysite/wp-includes/images/media/default.png, 300, 300, Array" alt="sponsor-image" class="sponsor-image">

    Any ideas? Bit new to WordPress / PHP so hoping it’s something obvious!

    Thanks

  • In the settings for the image field do you have it set to return the image URL? It appears that you returning an array. See the attached image that shows the settings in the image field.

  • Many thanks – simple fix for my idiocy!

  • Well, these things can be easily overlooked, I do it myself all the time.

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

The topic ‘Image paths broken (repeater field)’ is closed to new replies.