Home Forums Add-ons Repeater Field image ID thumbnail in repeater


image ID thumbnail in repeater

  • Hi,

    im stuck at getting the thumbnail of a image field into my template.

    	$attachment_id = the_field('bild_startseite_boxen');
    	$size = "baumann-thumb-big"; // (thumbnail, medium, large, full or custom size)
    	$image = wp_get_attachment_image ($attachment_id, $size);
        $rows = get_field('boxen_startseite');
        if($rows) {
            foreach($rows as $row) {
                // retrieve size 'large' for background image 
             	$output  = "<a href=". $row['derlink'] ."\n";
                $output .= "<li style='list-style-type:none'>\n";
                $output .= "  <div class='threecol boxes-start'>\n";
                $output .= "  <h3>". $row['uebeschrift'] ."</h3>\n";
                $output .= "  <img class='nojump' src=". $image[0] ."></img>";
                $output .= "  <p>" . $row['text_startseite_boxen'] . "</p>";
                $output .= "  <p style='color:#F36C3C;margin-top:0;'>mehr...</p>\n";
                $output .= "  </div>\n";
                $output .= "  </li>\n\n";
                $output .= "  </a>\r\n\n";
                echo $output;

    can someone guie me in the right direction? thanks! 🙂

  • I know it’s an old question and you’ve probably figured this out by now, at least I hope so, but for anyone else that has a similar question.

    The main problem with the above code is the first line

    $attachment_id = the_field('bild_startseite_boxen');

    the_field() echos the value, when you want to put the value into a variable you must use get_field()

    $attachment_id = get_field('bild_startseite_boxen');
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘image ID thumbnail in repeater’ is closed to new replies.