function image_fetch in Image 6
Same name and namespace in other branches
- 5.2 image.module \image_fetch()
- 5 image.module \image_fetch()
Fetches an image file, allows "shorthand" image urls such of the form: image/view/$nid/$label (e.g. image/view/25/thumbnail or image/view/14)
1 string reference to 'image_fetch'
- image_menu in ./
image.module - Implementation of hook_menu
File
- ./
image.module, line 658
Code
function image_fetch($nid = 0, $size = IMAGE_PREVIEW) {
if ($size == IMAGE_ORIGINAL && !user_access('view original images')) {
return drupal_access_denied();
}
if (isset($nid)) {
$node = node_load(array(
'type' => 'image',
'nid' => $nid,
));
if ($node) {
if (!node_access('view', $node)) {
return drupal_access_denied();
}
if (isset($node->images[$size])) {
$file = $node->images[$size];
if (file_exists(file_create_path($file))) {
$headers = module_invoke_all('file_download', $file);
if ($headers == -1) {
return drupal_access_denied();
}
file_transfer($file, $headers);
}
}
}
}
return drupal_not_found();
}