Skip Navigation

[Resolved] Display images of a custom field

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 3 voices.

Last updated by ericK-4 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1820433

Hi
Using oxygen builder, I want to display a list of image in a single page.
Making this code in code block, it crashes my site
<ul class="list-image">
<?php $images = types_render_field('slider-images');
foreach ($images as $image):?>

  • <img class="slide" src="<?php echo $image['sizes']['thumbnail']; ?>">
  • <?php endforeach;?>

    Is "types_render_field" is the good instruction to get the field ?
    Thanks for your help

    #1821107

    Nigel
    Supporter

    Languages: English (English ) Spanish (Español )

    Timezone: Europe/London (GMT+00:00)

    The types_render_field API function for images is described here: https://toolset.com/documentation/customizing-sites-using-php/functions/#image

    I think you should be including the size (thumbnail) as an argument in the types_render_field call, together with the attribute to specify you want only the corresponding URLs (rather than the image tags), something like

    $images = types_render_field( 'slider-images', array( 'size' => 'thumbnail', 'url' => true ) );
    
    #1822233

    Hi nigel,
    Thanks for your answer. I try this but it's still not work
    <ul class="list-image">
    <?php
    $images = types_render_field( 'slider-images', array( 'size' => 'thumbnail', 'url' => true ) );
    foreach ($images as $image):?>

  • <img class="slide" src="<?php echo $image; ?>">
  • <?php endforeach;?>

    #1822537

    Minesh
    Supporter

    Languages: English (English )

    Timezone: Asia/Kolkata (GMT+05:30)

    Hello. Thank you for contacting the Toolset support.

    It seems you are using the repeating image field. What if you try to use the following code:

    <ul class="list-image">
    <?php
    $images = types_render_field( 'slider-images', array( 'size' => 'thumbnail', 'url' => true ,"separator"=>",") );
    $images = explode(",",$images);
    foreach ($images as $image):?>
    <li> <img class="slide" src="<?php echo $image; ?>"> </li>
    <?php endforeach;?>
    

    More info:
    => https://toolset.com/documentation/customizing-sites-using-php/displaying-repeating-fields-one-kind/#using-html-separators

    #1823141

    My issue is resolved now. Thank you!