Here's an example of how to use a field instance's default image as a fallback when the individual image field itself is empty.
To briefly explain the concept, use field_get_items() to attempt to get the image attached to the entity (e.g. node, user, taxonomy_term, ...), then fallback to field_info_instance() if an image has not been uploaded.
Once an image is available to work with, set the $file
variable to the image reference, which will get rendered after calling field_view_value().
$field_image = field_get_items('node', $node, 'field_image');
if (!empty($field_image)) {
$file = $field_image[0];
}
else {
$info = field_info_instance('node', 'field_image', 'blog');
if (!empty($info) && $info['settings']['default_image'] > 0) {
$default_image_fid = $info['settings']['default_image'];
$file = (array) file_load($default_image_fid);
}
}
if ($file) {
$image = field_view_value('node', $node, 'field_image', $file, array(
'type' => 'image',
'settings' => array(
'image_style' => NULL,
),
));
print render($image);
}
All of this logic could be wrapped up into a helper function or simply used wherever needed.