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.

AttachmentSize
image_exact.patch.txt1.73 KB

#1

gordon - August 23, 2006 - 14:50

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.

AttachmentSize
image_exact.patch_0.txt 1.76 KB

#2

zigazou - January 4, 2007 - 13:03

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 :

<?php
if (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 :

<?php
if($exact[$size]==$size) {
?>

#3

izaak - February 6, 2007 - 17:01

I've cleaned it up a bit. Apply this patch AFTER #75147 (currently ready to be committed).

AttachmentSize
image_alter.patch 1.88 KB

#4

gordon - February 20, 2007 - 13:24

Bump, The hook_image_alter() patch has now been applied to HEAD, and 5

#5

JirkaRybka - July 11, 2007 - 19:16
Title:Use hook_modify_derivative() to change images.» Use hook_image_alter() to change images.
Version:4.7.x-1.x-dev» 5.x-0.1
Category:feature request» bug report
Priority:normal» critical

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_ORIGINAL instead 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.

AttachmentSize
img_exact_hook.patch 1.71 KB

#6

bermin - August 8, 2007 - 03:28

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.

 
 

Drupal is a registered trademark of Dries Buytaert.