function asset_img_output in Asset 5
Same name and namespace in other branches
- 6 inc/asset.routines.inc \asset_img_output()
Modified version of file_transfer()
Only output image formats and do not require src to be in file_directory_path
File
- ./
asset.module, line 713
Code
function asset_img_output($src) {
ob_end_clean();
$mimes = array(
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/x-png',
);
$info = pathinfo($src);
if (!$mimes[$info['extension']]) {
return drupal_not_found();
}
header('Content-type: ' . $mimes[$info['extension']]);
if ($fd = fopen($src, 'rb')) {
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}
else {
drupal_not_found();
}
exit;
}