You are here

function _emthumb_scale_image in Embedded Media Field 5

Same name and namespace in other branches
  1. 6.3 contrib/emthumb/emthumb.module \_emthumb_scale_image()
  2. 6 contrib/emthumb/emthumb.module \_emthumb_scale_image()
  3. 6.2 contrib/emthumb/emthumb.module \_emthumb_scale_image()
1 call to _emthumb_scale_image()
emthumb_emfield_widget_extra in contrib/emthumb/emthumb.module
when editing a node with an emfield, this will add our custom thumbnail upload form if allowed.

File

contrib/emthumb/emthumb.module, line 451

Code

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