function taxonomy_image_node_display_nodeapi in Taxonomy Image 5
Same name and namespace in other branches
- 6 contributed/taxonomy_image_node_display/taxonomy_image_node_display.module \taxonomy_image_node_display_nodeapi()
Implementation of hook_nodeapi().
File
- contributed/
taxonomy_image_node_display/ taxonomy_image_node_display.module, line 11 - Display taxonomy images in nodes where and when you want them.
Code
function taxonomy_image_node_display_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($op == 'view') {
if ($teaser == TRUE && !variable_get('taxonomy_image_node_view_teaser', TRUE)) {
return;
}
// If we are using the block module, then don't default to showing on a page.
if ($page == TRUE && !variable_get('taxonomy_image_node_view_page', !module_exists('taxonomy_image_blocks'))) {
return;
}
$preset = variable_get('taxonomy_image_node_preset', 'ORIGINAL');
$valid_nodes = array_filter(variable_get('taxonomy_image_node_view', array()));
if (isset($valid_nodes[$node->type]) && isset($node->taxonomy)) {
$images = array();
$view_link = variable_get('taxonomy_image_node_view_link', TRUE);
foreach ($node->taxonomy as $tid => $term) {
$image = taxonomy_image_display($tid, array(
'hspace' => 3,
), $preset, array(
'wrapper' => FALSE,
));
if ($view_link && $image) {
$image = theme('taxonomy_image_display', $image, $term);
}
$images[] = $image;
}
$node->content['taxonomy_image'] = array(
'#value' => implode("\n", $images),
'#weight' => variable_get('taxonomy_image_node_view_weight', -5),
);
}
}
}