function image_link in Image 5
Same name and namespace in other branches
- 5.2 image.module \image_link()
- 6 image.module \image_link()
Implementation of hook_link.
File
- ./
image.module, line 410
Code
function image_link($type, $node, $main = 0) {
$links = array();
if ($type == 'node' && $node->type == 'image' && !$main) {
$request = $_GET['size'] ? $_GET['size'] : IMAGE_PREVIEW;
foreach (image_get_sizes() as $key => $size) {
if ($size['link']) {
// For smaller images some derivative images may not have been created.
// The thumbnail and preview images will be equal to the original images
// but other sizes will not be set.
if (isset($node->images[$key]) && $node->images[$key] != $node->images[$request]) {
if ($size['link'] == IMAGE_LINK_NEW) {
$links['image_size_' . $key] = array(
'title' => $size['label'],
'href' => "image/view/{$node->nid}/{$key}",
'attributes' => array(
'target' => '_blank',
),
);
}
else {
$links['image_size_' . $key] = array(
'title' => $size['label'],
'href' => 'node/' . $node->nid,
'query' => 'size=' . urlencode($key),
);
}
}
}
}
if (!user_access('view original images')) {
unset($links['image_size_' . IMAGE_ORIGINAL]);
}
}
return $links;
}