_upload_image

Definition

_upload_image($file)
modules/upload.module, line 472

Description

Check an upload, if it is an image, make sure it fits within the maximum dimensions allowed.

Code

<?php
function _upload_image($file) {
  $info = image_get_info($file->filepath);

  if ($info) {
    list($width, $height) = explode('x', variable_get('upload_max_resolution', 0));
    if ($width && $height) {
      $result = image_scale($file->filepath, $file->filepath, $width, $height);
      if ($result) {
        $file->filesize = filesize($file->filepath);
        drupal_set_message(t('Your image was resized to fit within the maximum allowed resolution of %resolution pixels.', array('%resolution' => variable_get('upload_max_resolution', 0))));
      }
    }
  }

  return $file;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.