function asset_img_output in Asset 6
Same name and namespace in other branches
- 5 asset.module \asset_img_output()
Modified version of file_transfer()
Only output image formats and do not require src to be in file_directory_path
File
- inc/
asset.routines.inc, line 88
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;
}