function image_field_prepare_view
Implements hook_field_prepare_view().
File
-
modules/
image/ image.field.inc, line 205
Code
function image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {
// If there are no files specified at all, use the default.
foreach ($entities as $id => $entity) {
if (empty($items[$id])) {
$fid = 0;
// Use the default for the instance if one is available.
if (!empty($instances[$id]['settings']['default_image'])) {
$fid = $instances[$id]['settings']['default_image'];
}
elseif (!empty($field['settings']['default_image'])) {
$fid = $field['settings']['default_image'];
}
// Add the default image if one is found.
if ($fid && ($file = file_load($fid))) {
$items[$id][0] = (array) $file + array(
'is_default' => TRUE,
'alt' => '',
'title' => '',
);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.