function taxonomy_image_node_display_nodeapi in Taxonomy Image 6
Same name and namespace in other branches
- 5 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 97 - Display taxonomy images in nodes where and when you want them.
Code
function taxonomy_image_node_display_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
static $view, $view_teaser, $view_page, $preset, $view_link;
if ($op == 'view') {
if (!isset($view)) {
$view = variable_get('taxonomy_image_node_view', array());
$view_teaser = variable_get('taxonomy_image_node_view_teaser', TRUE);
// If we are using the block module, then don't default to showing on a page.
$view_page = variable_get('taxonomy_image_node_view_page', !module_exists('taxonomy_image_blocks'));
$preset = variable_get('taxonomy_image_node_preset', variable_get('taxonomy_image_imagecache_preset', 'ORIGINAL'));
$view_link = variable_get('taxonomy_image_node_view_link', TRUE);
}
if ($teaser == TRUE && !$view_teaser) {
return;
}
if ($page == TRUE && !$view_page) {
return;
}
$preset = $preset;
$valid_nodes = array_filter($view);
if (isset($valid_nodes[$node->type]) && isset($node->taxonomy)) {
$images = array();
foreach ($node->taxonomy as $tid => $term) {
$image = taxonomy_image_display($tid, NULL, $preset, array(
'wrapper' => FALSE,
));
if ($view_link && $image) {
$image = theme('taxonomy_image_display', $image, $term);
}
$images[] = $image;
}
$node->content['taxonomy_image'] = array(
'#value' => theme('taxonomy_image_display_images', $images),
'#weight' => variable_get('taxonomy_image_node_view_weight', -5),
);
}
}
}