function image_resize_filter_file_download in Image Resize Filter 7
Same name and namespace in other branches
- 6 image_resize_filter.module \image_resize_filter_file_download()
Implements hook_file_download().
File
- ./
image_resize_filter.module, line 100 - After adding to a text format, this filter will parse the contents of submitted content and automatically scale image files to match the set dimensions of img tags.
Code
function image_resize_filter_file_download($uri) {
// If this is a resized image, use the same access as the original image.
$matches = array();
if (preg_match('/^([a-z0-9\\-_]+:\\/\\/)resize\\/(.*)?-\\d+x\\d+(\\.png|\\.jpg|\\.jpeg|\\.gif)$/i', $uri, $matches)) {
$headers = module_invoke_all('file_download', $matches[1] . $matches[2] . $matches[3]);
if (in_array(-1, $headers)) {
return -1;
}
if (count($headers)) {
return array(
'Content-Type' => file_get_mimetype($uri),
'Content-Length' => filesize($uri),
);
}
}
}