You are here

public function ImageCrop::loadFile in Image javascript crop 7

Load the imagecrop settings for the given fid or filesource.

Parameters

$lookup fid of filesource:

$use_fid the first param is a fid:

File

includes/imagecrop.class.inc, line 53
Imagecrop class to handle the javascript imagecrop.

Class

ImageCrop
@file Imagecrop class to handle the javascript imagecrop.

Code

public function loadFile($filesource, $use_fid = TRUE) {
  if ($use_fid) {
    $this->file = file_load($filesource);
  }
  else {
    $query = db_select('file_managed', 'f');
    $query
      ->fields('f', array(
      'fid',
      'uid',
      'uri',
      'filemime',
    ));
    $query
      ->condition('uri', $filesource);
    $this->file = $query
      ->execute()
      ->fetchObject();
  }
  if (!$this->file) {
    throw new Exception('The image to crop was not found.');
  }
  if (!in_array($this->file->filemime, $this->allowedExtensions)) {
    throw new Exception('The file to crop was not an image.');
  }
  $this->file->filepath = file_create_url($this->file->uri);
}