I've added an image field in a content type, and set the 'Field Settings' -> 'number of values' to unlimited, which means users can upload unlimited images for this field.
then I build a view for this content type and expose the image filed to the view. what I 'd like is to expose only image in teaser view, and all images in the full view.
I use a template preprocess function
function MYTHEME_process_field(&$vars) {
$element = $vars['element'];
// Field type image
if ($element['#field_type'] == 'image') {
// Reduce number of images in teaser view mode to single image
if ($element['#view_mode'] == 'teaser') {
// something might be wrong here
$item = reset($vars['items']); // not working
$vars['items'] = array($item); // not working
}
}
}
In debugging this function, this 2 lines
$item = reset($vars['items']);
$vars['items'] = array($item);
doesn't seem to work. any suggestion?