function _imagefield_scale_image in ImageField 5.2
Same name and namespace in other branches
- 5 imagefield.module \_imagefield_scale_image()
1 call to _imagefield_scale_image()
File
- ./
imagefield.module, line 519 - Defines an image field type. imagefield uses content.module to store the fid, and the drupal files table to store the actual file data.
Code
function _imagefield_scale_image($file, $resolution = 0) {
$info = image_get_info($file['filepath']);
if ($info) {
list($width, $height) = explode('x', $resolution);
if ($width && $height) {
$result = image_scale($file['filepath'], $file['filepath'], $width, $height);
if ($result) {
$file['filesize'] = filesize($file['filepath']);
drupal_set_message(t('The image %filename was resized to fit within the maximum allowed resolution of %resolution pixels', array(
'%resolution' => $resolution,
'%filename' => $file['filename'],
)));
}
}
}
return $file;
}