In my custom type "Page" I've added an image field (field_page_cover_image) and applied image style to it.
<?php
$field = field_get_items('node', $node, 'field_page_cover_image');
if($field){
$theme_img = file_create_url($node->field_page_cover_image[$node->language][0]['uri']); //origional image path
if(isset($theme_img)) {
// print styled image
print theme('image_style', array('path' => $node->field_page_cover_image[$node->language][0]['uri'], 'style_name' => 'page_theme'));
}
}
?>
I have a requirement show this image (if uploaded) in all basic pages only (in a separate div container). For this I added the above code in `page.tpl.php
This code is working fine in all the pages but when I load search or other pages, I am getting error, as they don't have this field ($field).