Use hook_image_alter() to change images.
gordon - August 21, 2006 - 04:41
| Project: | Image Exact Sizes |
| Version: | 5.x-0.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | gordon |
| Status: | needs review |
Description
In the patch queue for the image module http://drupal.org/node/42835, I have added new hooks which allow the manipulation of the image by outsize modules when the derivatives are created.
So if new the derivatives are resized for 1 reason or another, this will do resize them at this time, instead of only during upload.
| Attachment | Size |
|---|---|
| image_exact.patch.txt | 1.73 KB |

#1
I have made some changes to the image patch, and now the new hook is hook_image_alter(), and handles all the images including the original.
#2
Your patch is very handy for me as I will use the Image publishing module. With it, I will be able to use the Gallery Remote software to upload galleries and without your patch, Image publishing bypasses the Image exact size module.
I've applied the 79737 patch to image_exact.module and 42835 patch to image.module and I works great except for one part : it does not use the Image exact size settings correctly.
In image_exact_image_alter function you have the line :
<?phpif (isset($exact[$size])) {
?>
This is always true for every existing size. This is due to the way the Image exact size module stores its settings (in fact, it lets the form manager do everything).
If the size is checked, we have
$exact[$size]=$size.If the size in unchecked, we have
$exact[$size]=0.Thus, if you check "Use exact sizes for image-nodes" in Image exact size settings, the thumbnail checkbox will always be checked (it's not a big problem as it is generally wanted this way).
So I suggest :
<?phpif($exact[$size]==$size) {
?>
#3
I've cleaned it up a bit. Apply this patch AFTER #75147 (currently ready to be committed).
#4
Bump, The hook_image_alter() patch has now been applied to HEAD, and 5
#5
Oops, I overlooked this issue, and made my own duplicate patch (very similar). Uploading just for reference.
I have one more thing: The new Image module on 5.x introduced
IMAGE_ORIGINALinstead of'_original'. So the original patch seen here should be probably updated, if used on 5.x. My one reflects this already.Also I change this Issue to bug-report critical status, because on fresh 5.1 install with all modules being recent version, the Image Exact doesn't work for image nodes at all. Seems that images are cropped 2 times, then blown away anyway and replaced by Image module's thumbnails. The patch is solving the issue completely.
#6
The previous comment confuses me a tad. I understood that the patch should have imagexact working with DRUPAL 5.2 and latest modules. It doesn't. Doesn't square the images selected.