I’m using Drupal 7 and create a module for my content thumbnail images frontpage display. Working this:
if(count($p_detail->field_slide) > 0){
$output .= '<div class="right">';
$output .= '<ul class="thumbs">';
$i=1;
foreach($p_detail->field_slide['und'] as $thumb):
$img_path = $thumb['uri'];
$img_url = image_style_url('tmb_240x117', $img_path);
$img_file = '<img src="'.$img_url.'" alt="'.$p_detail->title.'" />';
$output .= '<li>
<a href="'.$p_url.'">
'.$img_file.'
<div class="shadow"></div>
<div class="hoverimg"></div>
</a>
<div class="img_no">0'.$i.'</div>
</li>';
$i++;
endforeach;
$output .= '</ul>';
$output .= '</div>';
}
This codes is working. But i want show max thumbnails 6 images. For example, have got 20 images, show only first 6 images. If 2 images, only thumbnails 2 images. How can i do this?
You could just add this line below your foreach:
This will just end the foreach loop after 6 images has been printed.