Imagecrop with cropped Thumbnail
| Project: | Imagecache javascript crop |
| Version: | 6.x-1.x-dev |
| Component: | PHP |
| Category: | feature request |
| Priority: | normal |
| Assigned: | x_magnet_x |
| Status: | active |
| Issue tags: | crop, cropped, Imagecrop Thumbnail, thumbnail |
Jump to:
Hello,
I'm a newbie on Drupal and this Forum.
I extended the Imagcrop Javascript Module to generate Thumbnails on the cropped Image,
but I have a Problem after I delete the Image or the Content by the Forms.
The Thumbnail isn't removed.
My Idea was, that I make a Imagecache preset for the cropped Image and a preset for the cropped thumbnail,
because first the Image is cropped by the presets. After the User has confirmed the form he is able to crop the Image by himself.
In the Javascript Crop Action (Imagecache) the Admin is now able to choose a preset for the Thumbnail.
When the User or Admin opens the Javascript crop Panel and crop the Image, the thumbnail is generated by the thumbnail preset.
Yet the FileField Path (pathauto) isn't working (only renaming) - i try to fix it.
My Problem is with the Imagecache Module, because the first Thumbnail created by the Thumbnail-Preset (Content-Type -> manage Fields -> Display Fields (Teaser)) is overriden. That's working fine, but when I Would like to remove the Image (by the Forms), alle files are deleted, only the Thumbnbail is still stored.
I think that's a Problem with the Image Header. I think Imagecache put some Header Information into the file, so the Header Informations are different. but why does it work with the normal Imagecrop Module, because it's the same procedure?
I have no time for a Patch and it's really less code
so here is the code:
File: imagecrop_actions.inc -
Function: imagecrop javascript_form
put this code before "$form['disable_if_no_data'] = array(...."
$form['thumb_check'] = array(
'#type' => 'checkbox',
'#title' => t('Thumbnail'),
'#default_value' => $data['thumb_check'],
'#description' => t('if set Thumbnail would created'),
);
$form['thumb_preset'] = array(
'#type' => 'select',
'#options' => $presets,
'#title' => t('Thumbnail Imagecache Preset'),
'#default_value' => $data['thumb_preset'],
'#description' => t('The Imagecache Preset for Thumbnail Creation'),
);
and this into
File: imagecrop.module
Function: create_image_object
put this code before the end of the function (return FALSE).
if($cutoff != FALSE) {
$break = FALSE;
while (list($key, $val) = each($preset['actions'])) {
if ($val['action'] == 'imagecrop_javascript') {
$thumb_check = $preset['actions'][$key]['data']['thumb_check'];
$thumb_preset = $preset['actions'][$key]['data']['thumb_preset'];
$break = TRUE;
}
}
if($thumb_check) {
$preset_thumb = imagecache_preset($thumb_preset);
$thumb_path = 'imagecache/'.$preset_thumb['presetname'].'/thumb_'.basename($dst);
imagecache_build_derivative($preset_thumb['actions'], $dst, 'sites/default/files/'.$thumb_path);
}
}
Thanks

#1
Would love to be able to have the cropped image be ran through an additional imagecache preset. Right now I make the user crop the image twice. once for full view and once for teaser. If only there was a imagecache module that let run more than one preset on the image in a certain order.