function image_resize_filter_file_download in Image Resize Filter 6
Same name and namespace in other branches
- 7 image_resize_filter.module \image_resize_filter_file_download()
Implementation of hook_file_download().
File
- ./
image_resize_filter.module, line 109 - image_resize_filter.module
Code
function image_resize_filter_file_download($filepath) {
// If this is a resized image, use the same access as the original image.
$matches = array();
if (preg_match('/^resize\\/(.*)?-\\d+x\\d+(\\.png|\\.jpg|\\.jpeg|\\.gif)$/i', $filepath, $matches)) {
$headers = module_invoke_all('file_download', $matches[1] . $matches[2]);
if (in_array(-1, $headers)) {
return -1;
}
if (count($headers)) {
return array(
'Content-Type: ' . file_get_mimetype($filepath),
'Content-Length: ' . filesize(file_create_path($filepath)),
);
}
}
}