• Resolved 10rous

    (@10rous)


    hi there
    I need to display an image from a custom field, I just need the url but I get an array

    “138, , paella, , , http://malamarwakepark.com/wp-content/uploads/2013/11/paella.jpg, 1600, 1067, Array”

    custom field: fotos_platos
    repeater fields: foto_plato

    here’s the code:

    <ul>
    <?php while(has_sub_field('fotos_platos', 'option')): ?>
                            <li><img class="foto" src="<?php the_sub_field('foto_plato') ?></li>
                            <?php endwhile; ?>
    </ul>

    thanks a lot

Viewing 6 replies - 1 through 6 (of 6 total)
  • This should probably have been in the Advanced Custom Fields forum, however:

    $my_image = wp_get_attachment_image_src(get_sub_field('foto_plato'));
    <img src="<?php echo $my_image[0]; ?>
    Thread Starter 10rous

    (@10rous)

    thanks a lot

    Thread Starter 10rous

    (@10rous)

    i can’t get it to work

    it should be like this?

    <ul>
    <?php while(has_sub_field('fotos_platos', 'option')): ?>
    <li>
    <?php $my_image = wp_get_attachment_image_src(get_sub_field('foto_plato')); ?>
    <img class="foto" src="<?php echo $my_image[0]; ?>"/>
    </li>
    <?php endwhile; ?>
    </ul>

    Is this line right?

    <?php while(has_sub_field('fotos_platos', 'option')): ?>

    The ‘option’ should be the post ID or left out all together, it defaults to the current post.

    Thread Starter 10rous

    (@10rous)

    I’m working on a php cutom template, that line should be ok WPRanger, as it works for text custom fields in other div within the same template

    e.g.

    <?php while(has_sub_field('servicios_restaurante', 'option')): ?>
                            <li style="float:left; padding-left:10px; width:280px; clear:none; padding-right:10px; text-transform:uppercase; font-size:12px; line-height:20px;" id="serv_lista"><p class="dinpro"><?php the_sub_field('servicio') ?></p></li>
                            <?php endwhile; ?>

    I’ve tried to remove the ‘option’ but it doesn’t work either

    thanks

    Thread Starter 10rous

    (@10rous)

    solved, checking the image url option in custom field return option

    <ul>
    		<?php while(has_sub_field('fotos', 'option')): ?>
    		<li><img class="foto" src="<?php the_sub_field('foto') ?>"/></li>
    		<?php endwhile; ?>
    </ul>

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘display repeater custom field image’ is closed to new replies.