function imagecrop_image_styles_overview in Image javascript crop 7
Show an overview from the enabled image styles for this file. Show an example from the first (or selected) image.
Parameters
$fid fid from file to be viewed:
$style_name Style name that default needs to be shown:
$entity_type entity type from the field that triggered the imagecrop overview:
$bundle bundle from the field that triggered the imagecrop overview:
$field_name Field name that triggered the imagecrop overview.:
1 string reference to 'imagecrop_image_styles_overview'
- imagecrop_menu in ./
imagecrop.module - Implements hook_menu().
File
- includes/
imagecrop.admin.inc, line 128 - Administration tools for the imagecrop module.
Code
function imagecrop_image_styles_overview($fid, $style_name, $entity_type = NULL, $bundle = NULL, $field_name = NULL) {
$imagecrop = new ImageCrop();
try {
$styles = imagecrop_get_enabled_styles_for_crop($entity_type, $bundle, $field_name);
if ($style_name) {
if (!isset($styles[$style_name])) {
drupal_set_message(t('The image style to crop was not found.'), 'error');
throw new Exception(t('The image style to crop was not found.'));
}
}
else {
$style_name = key($styles);
}
$imagecrop
->loadFile($fid);
global $user;
if (!$imagecrop
->hasUserAccess($user)) {
drupal_set_message(t("You don't have permissions to crop this image."), 'error');
throw new Exception(t('Access denied for user @name on fid @fid', array(
'@name' => $user->name,
'@fid' => $imagecrop
->getFile()->fid,
)));
}
$imagecrop
->setImageStyle($style_name);
if ($entity_type) {
$imagecrop
->setEntityType($entity_type);
}
if ($bundle) {
$imagecrop
->setBundle($bundle);
}
if ($field_name) {
$imagecrop
->setfieldName($field_name);
}
$imagecrop
->addImagecropUi(TRUE);
$image_url = image_style_url($style_name, $imagecrop
->getFile()->uri);
$clean_url = variable_get('clean_url', 0);
$image_url .= !$clean_url || strpos($image_url, '?') !== FALSE ? '&' : '?';
$image_url .= 'time=' . $_SERVER['REQUEST_TIME'];
return theme('imagecrop_overview', array(
'style_selection' => drupal_get_form('imagecrop_style_selection_form', $styles, $imagecrop),
'viewed_style' => theme('image', array(
'path' => $image_url,
)),
'edit_url' => 'imagecrop/crop/' . $imagecrop
->getFile()->fid . '/' . $style_name . '/' . $imagecrop
->getEntityType() . '/' . $imagecrop
->getBundle() . '/' . $imagecrop
->getFieldName(),
));
} catch (Exception $e) {
$imagecrop
->addImagecropUi(TRUE);
watchdog_exception('imagecrop', $e);
return '';
}
}