You are here

function imagecrop_showcrop in Image javascript crop 5

Same name and namespace in other branches
  1. 6 imagecrop.admin.inc \imagecrop_showcrop()

Show the cropped image.

Parameters

$fid file id:

$presetid id of preset:

Return value

cropped version of chosen image

1 string reference to 'imagecrop_showcrop'
imagecrop_menu in ./imagecrop.module
Implementation of hook_menu().

File

./imagecrop.module, line 411
Provides a javascript toolbox through an imagecache action.

Code

function imagecrop_showcrop($fid, $presetid = 0, $module = '') {
  imagecrop_markup(FALSE, TRUE);
  if (imagecrop_action_exists() == TRUE) {
    $presets = return_presets($presetid);
    $presetid = $presets['presetid'];
    $file = create_image_object($fid, $presetid, $module, TRUE);
    if ($file != FALSE) {
      $module = !empty($module) ? '/' . $module : '';
      $output = theme('presettabs', $presets, $fid, $presetid, $module);
      $output .= '<div id="imagecrop_help">' . l(t('Click here to choose another crop area for this picture'), 'imagecrop/docrop/' . $fid . '/' . $presetid . $module) . '</div>';
      $output .= theme('imagecrop_result', $file->presetname, $file->filepath);
      return $output;
    }
    else {
      return '<div id="imagecrop_info" class="imagecrop_error">' . t('Image to crop was not found.') . '</div>';
    }
  }
  else {
    return '<div id="imagecrop_info"  class="imagecrop_error">' . t('No preset is found with the javascript_crop action so far. If you want to take advantage of this module, you will need to create at least one preset with that action.') . '</div>';
  }
}