public function ImageCrop::setImageStyle in Image javascript crop 7
Set the current cropped image style.
File
- includes/
imagecrop.class.inc, line 241 - Imagecrop class to handle the javascript imagecrop.
Class
- ImageCrop
- @file Imagecrop class to handle the javascript imagecrop.
Code
public function setImageStyle($style_name) {
$this->imageStyle = image_style_load($style_name);
if (!$this->imageStyle) {
throw new Exception('The image style to crop was not found.');
}
// add default settings
foreach ($this->imageStyle['effects'] as $effect) {
if ($effect['name'] == 'imagecrop_javascript') {
$this->width = $effect['data']['width'];
$this->startWidth = $effect['data']['width'];
$this->height = $effect['data']['height'];
$this->startHeight = $effect['data']['height'];
if ($effect['data']['xoffset']) {
$this->xoffset = $effect['data']['xoffset'];
}
if ($effect['data']['yoffset']) {
$this->yoffset = $effect['data']['yoffset'];
}
$this->isResizable = $effect['data']['resizable'];
$this->disableIfNoData = $effect['data']['disable_if_no_data'];
$this->resizeAspectRatio = !empty($effect['data']['aspect_ratio']) ? $effect['data']['aspect_ratio'] : FALSE;
$this->downscalingAllowed = !$effect['data']['downscaling'];
break;
}
}
}