You are here

function _linkimagefield_scale_image in Link Image Field 5

1 call to _linkimagefield_scale_image()
_linkimagefield_widget_prepare_form_values in ./linkimagefield.module

File

./linkimagefield.module, line 316
Defines an link image field type. linkimagefield uses content.module to store the fid, and the drupal files table to store the actual file data.

Code

function _linkimagefield_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 was resized to fit within the maximum allowed resolution of %resolution pixels', array(
          '%resolution' => $resolution,
        )));
      }
    }
  }
  return $file;
}