Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here's a re-roll of a patch I did last year.
I thought I posted it, but can't find it again...
Basically - I want to run imagecache over the built-ins, and not have to screw up other modules and themes by using imagecache pathnames.
When image_build_derivatives runs - it may use imagecache presets.
The UI is quite ugly due to the way that image.module has themed its table, but I managed to shoe-horn the setting into it anyway.
Comment | File | Size | Author |
---|---|---|---|
#162 | 231622-image-imagecache_integration-20101012.patch | 11.11 KB | dman |
#147 | 231622-image.imagecache_integration-20100827.patch | 11.64 KB | dman |
#137 | image.imagecache_integration-20100715.patch | 11.89 KB | dman |
#131 | 231622-131.image_.expand-presets-imagecache.patch | 11.5 KB | joachim |
#128 | image.imagecache_integration-20100714.patch | 11.78 KB | dman |
Comments
Comment #1
dman CreditAttribution: dman commentedScreenshot failed for reasons unknown. twice. So here's the one I prepared earlier.
And a patch with 5 whole spaces added to it to make it code formatting-compliant :-}
Comment #2
dopry CreditAttribution: dopry commentedHey dman I totally love this patch, but Feel it could be a great standalone module... I'm not sure that I really have the personal bandwidth to track the changes in image.module as well as imagecache.module...
I've even been thinking of splitting out a separate imagefield_imagecache.module to expose imagecache formatters to CCK. To make my life as the maintainer of imagecache easier...
How would you feel about making this a stand alone module? I'd really love to see it in the wild... or making it a part of image.module officially. I really want to keep imagecache simple..
.darrel.
Comment #3
dman CreditAttribution: dman commentedWell, this addition is only a bit of glue between the modules, with no character of its own, so I don't see it as a stand-alone entity really.
However, It looks like I can roll it up independantly, so I'll try that. I hear you about tracking the changes in dependancies, it's a bit hairy.
Still, not worth a hook or API to get image presets to look for any other processes... that's the long-term way to do this.. but overkill when AFAIK imagecache is the only one ever to provide such a function...
I'll turn it into a stand-alone contrib and see if the image guys want it. I do NOT want to create a project for this.
.dan.
Comment #4
yngens CreditAttribution: yngens commentedboth of the patches produced Hunk lines
Comment #5
dman CreditAttribution: dman commentedThis one goes against HEAD - revision 1.54. Which did you try it against? It may have been tagged against 5.x.2.0-beta wrongly. There's too many threads for me to figure nowadays.
Comment #6
dopry CreditAttribution: dopry commentedYeah I'm not really sure whether the image/imagefield integration should be a part of imagecache or image.module.... I think I may roll this as a contrib imagecache module and move the imagefield integration to the same... maybe move imagecache_profiles there as well... I want people to be able to pick and choose the middleware for their Drupal... not to get a kitchen sink with imagecache.
Comment #7
sun+1
Providing this as an optional contrib module in the ImageCache project/package sounds good. But I think this patch enhances Image.module in reality, not ImageCache. So providing this feature in the Image package might make more sense.
Moving to Image's queue to hear about drewish's opinion on this.
Comment #8
dman CreditAttribution: dman commentedI guess you are right. It is adding to image.module more than vice versa.
And I have to do some hoopy mess to get the table/form formatted whan trying to form_alter from an external module. image runs its own theme to do form layout ... but that means extending it with a column was hard! It would be better if image.module did this extra form building internally.
Comment #9
xurizaemonsubscribing.
dman - anything come of this with image.module? should we be checking an issue over there too?
Comment #10
xurizaemonI tried this patch out today. As the patch doesn't remove any existing code, I just added it as _form_alter() and _image_alter() in a separate module.
Here are my results:
* It adds the UI to image.module's settings page. I can add a new image preset and choose an imagecache profile.
* It adds the matching select option to my image_assist popup. However, imagecache profile 1 replaces image setting 1 - so my image.module setting "Original" is replaced with the first imagecache preset.
* I don't see any difference in the resulting inserted image.
dman, I'm intrigued by your statement,
I hadn't noticed imagecache do this - can you elaborate some?
Would love to have a hand in pushing this further. It is driving me batty that a great toolkit like ImageCache doesn't play friends with TinyMCE :)
This episode was brought to you by the version numbers:
* ImageAPI + ImageAPI GD 5.x-1.1
* ImageCache 5.x-2.0
* Image Assist 5.x-1.6
* TinyMCE 5.x-1.9
Comment #11
dman CreditAttribution: dman commentedMy reluctance to use pure-imagecache methods and instead shoehorn imagecache behaviour into image.module presets is straightforward.
Many of the image-modules I've been working with respect the image.module presets (_original,thumbnail, preview etc), and often present them as settings to choose from - eg views, image_attach, taxonomy_image.
They were not (last year anyway) as savvy about presenting imagecache options, and so to use imagecache usefully either some code, or more often some tricky (unconfigurable) custom theming had to happen.
It seemed better to add the options to image.module, then draw on them from the other modules, than to add imagecache-compatable additions to each of these third-party mods. That's pretty much all I meant by 'screwing up the paths' - anything that used imagecache had to be imagecache aware and use odd long imagecache pathnames. I prefer to use the pathnames as managed by image.module
That said - I've found in a recent (several thousand image) project, that forcing image.module to build all its derivatives at once is a bit painful for the server, and possibly on-demand imagecache behaviour also has its place!
Comment #12
xurizaemonThanks for the reply. I agree that it's better to get this into core image.module than imagecache - and also that on-the-fly generation is generally more efficient (because images don't get created until they're used).
I'll have a look at why the imagecache presets are overwriting, rather than being appended to, the image presets in that form.
Would be keen to liase with you in pushing this one forward. We have an (NZ-based) project which wants some similar functionality, so it would be good to touch base. (Did I email you separately? I meant to!)
Comment #13
antiorario CreditAttribution: antiorario commentedsubscribe
Comment #14
luco CreditAttribution: luco commentedworks like a charm. I love it. doesn't it just make sense? how come no one'd thought of that before?
here's a patched version of the module, for all those not-tech-savvy such as meself; just rename it to imagecache.module and replace the original file. I didn't patch this properly, I only added the last lines. but worked anyway and might come in handy for some folks out there.
(I don't have to tell you to backup and test, do I?)
I'd like to ask developers: PLEASE post PATCHED versions of modules. the whole point of using Drupal is to abandon lines of code. I know patching is simple for a webdeveloper, but webdesigners get really stuck in that point. ok? ;]
anyway, kudos to ye, dman. keep up the good work.
Comment #15
dopry CreditAttribution: dopry commentedcommited with UI modifications as imagecache_image.module...
Functionality untested. cheers. open new bugs for it if they arise...
Comment #16
EgonO CreditAttribution: EgonO commentedseems to work fine. but if one changes the imagecache-preset the derivates are not updated. one have to manually delete all the preview/thumbnail files on server.
derivate-images should also be put on the corresponding imagecache-folder not directly in the files/images folder (actually they are named xyz.preview.jpg & xyz.thumbnail.jpg directly in the files/images folder)
Comment #17
dman CreditAttribution: dman commentedTrue.
This integration mimics the image.module behavior closely, just using imagecache processing at the time image.module wants to make its derivatives.
This is deliberately to be transparent to the other modules that are built around any of that existing functionality. Several (like lightbox) count on image derivatives being in the predicted location. Others check for the file existence, which would fail if imagecache was being dynamic.
If image.module makes a thumbnail, it saves it in the normal place. Yep. That's intentional.
If image.module rebuilds its derivatives, the derivatives get rebuilt. On demand according to image.module behaviour.
Basically there is no 'caching' magic going on here anymore, only the imagecache filter processing. This was initially created to support watermarking thumbnails etc that imageapi does and image.module doesn't.
This request is reasonable in other use-cases, but has some awkward implications, as the two modules work quite differently. imagecache doesn't keep a database list of files, so relies on just deleting full directories. That is incompatible with the way image.module keeps a list of attached files in the file table. Updating (removing) files would require sending messages to the DB that the files were now missing. Altogether not really what I'd intend.
An optional approach, with different code, that does what you want could be created, but it's essentially a different approach, code-wise.
Comment #18
dopry CreditAttribution: dopry commentedI'm keeping this closed.. the integration is only to allow image.module to use the imagecache processing pipeline. You'll have to rebuild derivatives from image.module to update your thumbnails. It can be a time consuming process, but is intended to do things the way image.module does things.
Comment #19
PeteS CreditAttribution: PeteS commentedWhen trying to use this, I pretty much immediately get errors (posting the form on the Image settings page) complaining about how a width and height weren't set. Then, it seems that the regular image derivative building is still taking place, and so I get a dozen pages of errors about trying to generate ""x"" images. I certainly expect bugs in any new or existing release, but am I completely missing something here or does this just not work at all?
Comment #20
dman CreditAttribution: dman commentedSo were the width and height not set? Is there a reason you didn't want to follow the instructions?
Image.module validation still requires them to be set to something, even if they are overridden or ignored by the imagecache process. It's sorta a quirk, but it's described in the help text there on that page.
EDIT:
Apologies, I was referring to an earlier version of the UI. I see the current DRUPAL-5--2 (dev) has been slightly modified.
But I'm not seeing the complaints you mention either. What exact image.module and imagecache.module checkouts do you have?
Comment #21
dman CreditAttribution: dman commentedOn investigation, it looks like there is an issue with the current 'imagecache' selector UI totally replacing the previous 'preview' and 'thumbnail' sizes. Although they are in the form, they are hidden.
Now, this works (for me) and looks a little better in the UI than my earlier attempt. But does force the user to go all-or-nothing. Either use imagecache for every resize, or none. No mix-and-match. Which does eliminate some confusion (which I'd introduced :-} ) over which dimensions really get used.
Although the hidden default thumbnail sizes still work as a fallback, they are not configurable.
The UI is simpler, and basically DOES work. But there's this hidden issue there. A tiny bit of lost/confusing functionality. I can live with it, but we can probably document it a bit.
... I still can't replicate the errors PeteS describes. ( image.module DRUPAL-5--2 ) ( or DRUPAL-5--2-0-alpha2 )
Comment #22
dman CreditAttribution: dman commentedOK, I've now been able to replicate the problem on a clean install(s)
Here's a significant re-write, that now uses the image.module 'operations' selector to choose the image process. So it co-operates with the image settings form instead of mutilating it.
... Actually, it SEVERELY mutilates the FAPI behind it by inserting the imagecache options, then extracting them, hiding them, and tricking image.module into thinking that all is normal. But the UI is perfect.
I've thrown out the theme overide we were using, and added logic to the validation phase.
So I'm attaching a D5 patch, the full D5 module file for convenience, and also a D6 port of the same thing!
The CVS I could see imagecache-6.x-1.0-alpha2 didn't even have this addition in it, so I guess we can call this a clean start.
Requires/works with todays image.module dev releases for D5 and D6. I hope they are stable.
Comment #23
dman CreditAttribution: dman commentedOh, better re-open.
Maybe I should have made a new issue ... but I had this thread open for a few hours waiting to post this fix :-/
Comment #24
nicholasThompsonI am also suffering this problem...
My 'hack' was to force the form value to 1 by adding this below the form_alter 'hidden' lines...
I've just learned the implication of this... When I submit an image using image_attach the image ends up being 1x1!
I might re-checkout the module and try your method @dman.
Comment #25
nicholasThompsondman - I just tried your patch and am still getting the following issue when I submit an image...
Is this related?
Comment #26
nicholasThompsonAh fixed - using your patch I had to change the "Original" preset for an Image to Scale Image and then leave the width and height blank. Works perfectly now!
I can +1 this as "good". Nice one dman! :)
Comment #27
dman CreditAttribution: dman commentedThat hack was the first quick way out, yeah, but clearly it's cheating. Any problems you got would have been due to an unclean setting, I'm pretty sure you won't get that on a new site.
I'm happy to finally have fixed the UI. Ever since I started, the image settings table layout has been tricky to work around. Now I think it's the way it should be.
The code however could be mode drupal-hook-based instead of the form hack it is now ... but I'll bounce that off the image.module guys I guess.
Comment #28
dman CreditAttribution: dman commentedbump.
http://drupal.org/node/231622#comment-973178
is a stand-alone update of the imagecache+image.module glue.
It only affects its own imagecache_image.module file, so won't break anything that's not using it.
It's got a D6 version too.
bump-a-dump
.... yeah, I definately should have made a new thread :-}
Comment #29
HansBKK CreditAttribution: HansBKK commentedNoob here seeking clarification, please correct any of the below summary if I'm mistaken:
Function:
This allows one to use imagecache with the Image module rather than CCK/Imagefield, but loses the dynamic caching behaviour, only creating static derivatives, which will then be used as if they had been created by the Image module by all the other related modules that work with such files (files? - see below)
Procedure:
install and configure imagecache as usual
download imagecache_image.module.txt from http://drupal.org/node/231622#comment-973178 and rename it to imagecache.module
Overwrite imagecache.module in the imagecache folder with the new version
Questions:
Are the images ("original" + derivatives) files stored in the filesystem, or BLOBs stored in the database?
How specifically does one delete the derivative images previously created by Image module and force their regeneration with the new imagecache process?
How should this be set up to protect from this scenario: Image and Imagecache move on in the development cycle and no one does anything further with this fork?
TIA. . .
Comment #30
dman CreditAttribution: dman commented1 - they are files, stored in exactly the same way and place that image.module stores its an_image.preview.jpg files.
2 - image.module provides a 'regenerate derivatives' button for each image, and a bulk function through the content manager to do the same. Mass regenerations can also be triggered by changing any dimension in the derivative preset screen.
3 - There's been some support for this utility in theory, I'm not sure why we just haven't got around to rolling it in. I'm not pushing it in myself as a matter of courtesy, because as I submitted the change, I'm not also going to say it's RTBC.
But if at any stage you choose to upgrade to a clean, unpatched distro, then things will continue working as before, and the imagecache-processed derivatives will be overwritten by the plain image.module processed ones. You loose the feature by removing the code, but you don't loose any data or anything.
Comment #31
HansBKK CreditAttribution: HansBKK commentedThanks very much for your clarifications, seems like a good way to go and thanks for putting in your time to help END THE MADNESS that is images in Drupal
I'd also greatly appreciate (if you have time) your letting me know if I'm completely off-base with this idea on combining the two main methodologies:
"Images in Drupal - Future-proof methodology (Image module + imagefield together)"
http://groups.drupal.org/node/14974
Comment #32
HansBKK CreditAttribution: HansBKK commentedSorry to bother you Dan, but in following my above step-by-stop, I've just downloaded the current imagecache-5.x-2.x-dev from 2008-Jul-24. When I went to enable it, I saw along with imagecache module itself and its UI, a third module called "ImageCache 4 Image 5.x-2.x-dev Imagecache integration for Image module"
Q1 So is this equivalent to or later than your imagecache_image.module.txt contained in http://drupal.org/node/231622#comment-973178?
In other words am I good to go with the former without having to install anything else? Or is the latter one later or otherwise still needed?
And Q2 I've currently got Image v5.x-1.9 working, should I upgrade to 5.x-2.x-dev or 5.x-2.0-alpha3 (looks like they're the same) before enabling your fork? Note this is all going to be for a production site. . .
Finally Q3 is there anything we non-coding hoi polloi can do to help campaign for this functionality to get rolled into the mainstream Image?
Thanks for your help, and all your great work for the community.
Comment #33
dman CreditAttribution: dman commentedHeh.
Sorry, I was severely jet-lagged last week!
I'd totally forgotten that "ImageCache 4 Image" is now part of the image package. It's a fully compatable and independant glue module. And I fixed up the UI better too. I should have closed this thread.
The glue module - available only to those that want it, not affecting those that dont, using only public hooks to do the job, is a perfectly fine place for it to live. No more action needed, just a bit more MEMORY on my part.
It should just bloody work, But probably it's imagecache DRUPAL-6--2, the 6--1 is quite outdated, and the alpha/dev has been stable for months.
Comment #34
HansBKK CreditAttribution: HansBKK commentedThanks for the lightning response Dan, and rest assured any and all brain-farts are completely by the by, your brain's forgotten 100x of what's in most of ours'.
I'm happy to know I'm good to go with that dev version of IC without needing anything further from this issue thread. And although I like the "just work" comment, I'm still a bit confused by your D6-related comments since I'm on Drupal 5.
Therefore I'm still not clear on what version of Image module I should be on to work with your "ImageCache 4 Image" module - a one-letter answer will suffice:
>> I've currently got Image v5.x-1.9 working, should I upgrade to A 5.x-2.x-dev or B 5.x-2.0-alpha3 or stick with C stable v1?
Thanks 2
Comment #35
HansBKK CreditAttribution: HansBKK commentedHope you don't mind me talking to myself here, but for the benefit of those coming here later. . .
I went ahead and tried implementing "ImageCache 4 Image" on a scratch site with Image v5.x-1.9, and so far everything looked A-OK, as long as I only selected IC presets for the first three rows in the Image UI (original, thumbnail and preview, left column options were grayed out.) But when I tried to fill in from no. 4 on, where there's empty left-hand fields to fill in with my own preset names, Image kicked out an error message about width and/or height not being set, as per http://drupal.org/node/231622#comment-938919 above. However, the traditional fields in the middle columns that were used by Image before for setting the WxH parameters are now completely missing from the UI.
I figured this may well mean I should be using Image 5.x-2.x-dev version (2008-Aug-17) so I upgraded, ran update.php selecting Image "5200", tables updated but no joy.
Trying another tack, I disabled "ImageCache 4 Image", went to the original Image config UI, put in dummy width values and saved, then re-enabled ImageCache4Image everything's hunky dory.
Uploaded a JPG and bah-da-bing bah-da-boom, one big original and 5 derivatives sitting in the Images folder!
BTW Q1 I still don't know whether I should have upgraded the Image to 5.x-2.x-dev or not, good thing I did all this on a scratch site :)
Subsidiary Q's:
Q2 I guess the imagecache folder will remain empty unless I start to also use imagefield access methods?
Q3 As long as I stick to Image type nodes (as opposed to Imagefield CCK ones), then Views (and everything else) should be able to pick these up as if they were Image-generated, right?
Q4 I wonder if I do start to use Imagefield nodes, can I configure it to use the same directory/filenames as Image? If not, NBD, disk space is cheap eh?
Finally, I'm so far a very happy camper Dan, thanks so much for this brilliant effort.
IMO this should get folded into the mainstream Image module now, one step closer to the grail of ending the insanity that is images in Drupal.
Maybe this is a good place for you (that is everyone but Dan da man) to put your +1:
http://drupal.org/node/145071
Comment #36
nicholasThompsonI can personally "+1" DMans patch from #22 with one "minor" tweak...
The patch worked PERFECTLY if I added one preset, but the second preset caused headaches. I ended up rounding it down to the fact that derivative generation was passing a "preset" over which has zero width and height. Fix? Simply add a hardcoded 1x1 width and height... Seems to fix everything :-)
I've attached my revised version of the patch... Anyone care to review? :-)
Comment #37
HansBKK CreditAttribution: HansBKK commented@nicholasThompson - I don't yet know how to patch so I can't test your code, but rather than working from the code in dman's post above, I reckon using the "imagecache 4 image" module shipping as part of the latest dev release of Imagecache would be the way to go. I had no problems at all with it once I created the "dummy presets" in Image's config screens before enabling I4I - these settings get ignored, but apparently need to be there.
Answering some of my own questions from knowledge gained in the meantime, again for the benefit of those coming here later:
Q1 still don't know, if someone gets the latest dev of Imagecache's imagecache4images working with the stable version of Image, please post here to let us know.
Q2 yes, Imagefield will dynamically generate its derivatives of images stored in ANY location and uploaded from ANY source simply by using its URL access scheme, and nothing will appear until then.
Q3 yes, so far all Image-module compatible add-ons treat the derivatives created by imagcache4image as if they were natively created by Image module.
Q4 haven't done any testing, but from discussions elsewhere seems to be a bad idea to have different modules "sharing" the same files - let each have full "ownership" over its own files, and if you need to say save images as nodes with Image module AND embed them in Imagefields, you need to accept the image files being duplicated in different folders.
Comment #38
dman CreditAttribution: dman commentedI'm having a heck of a time retrieving imagecache_image from CVS.
It's there
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagecache/...
But doesn't seem tagged right, and is not coming with any checkouts I've tried so far.
Thus it's hard to update and test - at all.
Can someone investigate its CVS status?
Comment #39
dman CreditAttribution: dman commentedOK. Here is a re-roll/re-port.
Working against todays imagecache.module HEAD (D6) and image.module HEAD (D6)
I sorted out the validation as per
http://drupal.org/node/318434
I've worked around the dimensions problem noticed in
http://drupal.org/node/303751 and http://drupal.org/node/329527
I added a trigger that DOES flush image.module presets when a linked imagecache preset changes as discussed ... um, in another issue somewhere. During testing I found it a bit unintuative, and image.module does just rebuild on-demand, so I'll let the system take the hit.
Hopefully the code is even tighter (I use more of the D6 Form API tricks).
Changed the description a little and the dependancies are imagecache and image.
The CVS branch this module USED to be on seems to be broken, so I can only imagine these files should be added anew. Can we try again?
If not, hey, it can even be downloaded as-is and be its own little working distro.
Comment #40
open-keywords CreditAttribution: open-keywords commentedthis thread was about D5 and image-cache 2.x
Comment #41
dman CreditAttribution: dman commentedOK.
It was.
But this didn't make it in correctly back then, and the idea is that new features go into HEAD and get backported, maybe. So the issue was brought forward, even though there is a working patch there for D5.
If it makes you happier, I'll update the status. Done.
Comment #42
HansBKK CreditAttribution: HansBKK commentedAnd just to confirm re D5, I've had zero problems with the "imagecache 4 image" module contained in
imagecache-5.x-2.2
working together with
image-5.x-2.x-dev-2008-Aug-17
I used the dev Image module when testing and never did try it with the released one, still waiting for feedback on whether that should work or not (I suspect yes)
Comment #43
dman CreditAttribution: dman commentedThere were issues with sizes getting unset or needing to be set to something to make image preset validation work, even though they were being overridden, but I think we've got workarounds in place for that.
There was just some sort of CVS split that made it tricky to check a fixed version out. The 'released' one is inaccessable to me :-/ Dunno why.
Comment #44
PlayfulWolf CreditAttribution: PlayfulWolf commented+1
this module is definitelly "TOP 1" glue module for Drupal.
one small question: have any plans for Drupal 6 version?
Comment #45
dman CreditAttribution: dman commented#39 is D6.
Just needs CVS love.
Comment #46
drewish CreditAttribution: drewish commentedthough now that imagecache is getting pretty stable i've come around to the idea of making the image module dependent on it for thumbnails. what do you think of moving this issue back over there?
Comment #47
dman CreditAttribution: dman commentedUrr...
If you mean what it sounds like, that doesn't sound like a great idea to me.
I think there are a larger number of sites that get by with just the image.module quite happily - than there are imagecache.module users that don't use image.module. I may actually be wrong with the growth of imagefield + imagecache uses (?).
I appreciate the idea of reducing the duplication of the current 'scale' function provided by the basic image.module. But that's not a huge hit or inefficiency, and the ability to "just work" is not worth sacrificing to reduce the code by 3%.
I don't think imagecache should be made required for image.module. Adding a flashy requirement to a cool, simple, purpose-built module like that should not be necessary.
...although the derivative generation process could possibly be abstracted a little more to make it friendlier to plug the two together. ... even though this imagecache_image.module manages to do it OK, if a bit sneakily.
I still see the imagecache_image glue module as conceptually belonging to imagecache. Even though the code itself does mainly do its business by extending image.module, the functionality and feature set is all about imagecache.
Comment #48
AltaVida CreditAttribution: AltaVida commentedsubscribe
Comment #49
scroogie CreditAttribution: scroogie commentedI'd actually like to see the integration. Looking forward to your decision.
Comment #50
dopry CreditAttribution: dopry commented@drewish: I'm in favor of moving it back to image.module as well...
Comment #51
dman CreditAttribution: dman commentedI really don't mind where it lives - as long as someone wants it.
Please, just take it and commit somewhere.
.dan.
Comment #52
scroogie CreditAttribution: scroogie commentedYesterday I had a weird problem with the page where I'm using this page. An image where the derivatives had to be regenerated called convert with size parameter "0x0!" and I had a duplicate entry for "Original" in the image settings. I don't know if it's because of this patch or because of my test site (im trying out a lot of stuff, so it might be my fault). Did someone else see this already?
Comment #53
altavis CreditAttribution: altavis commentedImage 6.x-1.0-alpha4, ImageCache 6.x-2.0-beta5 and this ImageCache for Image - Image derivatives cannot be properly set using ImageCache presets.
# warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /public_html/d6abc/includes/image.gd.inc on line 95.
# warning: imagecolorallocatealpha(): supplied argument is not a valid Image resource in /public_html/d6abc/includes/image.gd.inc on line 97.
# warning: imagealphablending(): supplied argument is not a valid Image resource in /public_html/d6abc/includes/image.gd.inc on line 98.
and so on ....
Comment #54
greggus-1 CreditAttribution: greggus-1 commentedsubscribe
Comment #55
thamasI tried the imagecache for image yesterday with a fresh Acquia Drupal install, but it did not work.
I set image to use imagecache to create the Original, Thumbnail, Embedded sizes. After submitting the dimension set automatically 1x1, and it is not ignored: when I create a new image it is inserted 1px x 1px size. :o(
Comment #56
Geekish CreditAttribution: Geekish commentedI had the problem with the 1x1 images too. I found that any time I tried to let imagecache do ANYTHING with the original, it and all my other derived images became 1x1. I had to remove the imagecache preset and let the image.module handle the original image (you can still use the basic scale/scale & crop provided by image.module). All the other imagecache presets worked fine after I changed that back.
Edit: I may have spoken too soon. It seemed to be working fine for a while, but the 1px images are happening again.
Another edit: Okay, now it works again. Sort of. I flushed all the imagecache presets (again), and new images seem to generate derivatives properly.
Problem is, even though all the derivatives show up in the right sizes on the image node, if I try to insert them into a page, then img_assist turns them into thumbnails or 1px images (depending on the browser). Grr. Doesn't seem like an img_assist issue, because if I revert to the image.module presets, the image is inserted at the proper size (after recreating the derivative images). However, when I view the img_assist Filter tags, it gives the dimensions as 1x1 again. So I think somewhere along the line, the imagecache presets are failing to override the image.module dimensions (which I notice become 1x1 when using the imagecache for image module).
Comment #57
Geekish CreditAttribution: Geekish commentedIn case anybody is curious, I tried a fresh install with a different set-up. In both cases I started with the Image module, Imagecache, and Imagecache for Image (of course). However, instead of using Img_assist (a longtime staple of mine) and FCKeditor for inserting photos, I tried Image Browser and FCKeditor.
Works like a charm so far. No 1x1 images or reducing everything to thumbnails. Of course, imagebrowser is intended to work with both image and Imagecache, so..
Anyway, it looks like Img_assist was the source of my troubles. This new set up allows me to use Imagecache/Imagecache_actions on both image nodes and on images inserted into a text field via FCKeditor, thus meeting both my site requirements (images as nodes and automatic image sizing/watermarking).
Comment #58
Hetta CreditAttribution: Hetta commentedComment #59
dman CreditAttribution: dman commentedthe 1x1 preset was just a workaround because image.module wouldn't allow a preset without dimensions. imagecache actions do not all present a final size in a way that the rest of the image routines expect to see. imagecache is more flexible than was anticipated.
The fix - to allow the possibility that an image.module preset does NOT have a defined size - needs to be fed back to all the contrib modules that used to assume it was always there.
Try 1000x1000 - should work just as well.
I'll take a current checkout of the image* modules and see if there are still problems.
Comment #60
peterjmag CreditAttribution: peterjmag commentedI need to test this out a bit more, but I'd love to see this module committed to the appropriate project.
Comment #61
sunImage Assist has nothing to do with this issue.
Comment #62
dman CreditAttribution: dman commentedTo revisit...
I'm doing a heap of image-suite revisions and updates this weekend (lots of docs in the works) and I'd like to see this glue module back on the table.
The bug touched on here is all stemming from the image preset size setting validation step
In order for imagecache_for_image to survive, that assumption that all presets return a fixed set of dimensions has to be worked around. Currently quite badly.
If that validation function also checked that the preset process was one of the known 'scale' or 'scale_crop' before setting its error, then the additional imagecache presets (which do not always know their size ) could be inserted into the pipeline without hackery.
If image.module allowed that, I'll do a re-roll and see where we are at.
I Do not know of the side-effects further down the track of having a preset with undefined dimensions. Does it give image_get_derivative_sizes() a division by zero? That's why I haven't tried harder.
.dan.
Comment #63
luco CreditAttribution: luco commentedI'll test it any patch you post here. I need this integration working ;)
Comment #64
dman CreditAttribution: dman commentedWith the November version I've tried again, and it still works just fine out of the box - with todays checkouts of imagecache & image.
It seems that this IS all about img_assist! That's the only situation that I see reports about.
image module didn't mind having dummy values in the size array, but it seems that img_assist is requesting them and using them.
No img_assist, no problem.
This implies that any change will have some sort of downstream effect, and require a patch to img_assist!
I'll see what needs to be done to allow null dimensions to work within image.module, then we'll have to let img_assist.module know that it needs to allow for that.
Comment #65
dman CreditAttribution: dman commentedHere is a re-roll
- the November version wasn't broken - it's just that img_assist (and possibly other extension modules) assume that image.module presets always have a known, fixed size.
I don't know what to tell them, when imagecache presets may have a width of '40%' or a canvas adjustment of '+20px'. They need to deal with a variable-sized preset.
This update includes a lot of tweaking. Importantly it now requires a patch to image.module that allows image.module operations to actually delegate to other modules.
The built-in image.module [scale, scale_crop] operations are hardcoded and limited. This patch attempts to fix that.
Now... image.module is unlikely to be officially patched in a hurry. New features in D7, ported back, yadda yadda.
But imagecache is into core for D7, so there should be a lot more synergy there. then.
If you want this feature now:
- use the November version, it's OK.
- If that produces problems with 1x1 images or validation complaints, use this version and patch image.module
- or if it's just img_assist that's bugging you, try fixing up img_assist to allow for undefined sizes.
I tried img_assist today, and it won't even place my derivative presets, so I don't know what's supposed to be happening.
Comment #66
joachim CreditAttribution: joachim commented@dman
Image module will be patched if patches have been tested and the maintainers agree to committing the patch.
I see sun has left this issue as being on 6.x-1.x-dev, so I assume he is in favour of this going into that branch. So am I :)
I've had a super-quick glance at what you've linked in the comment above and the first thing that springs to mind -- if you're patching image.module anyway, why not patch it to add a hook_image_operations, rather than shove your presets in with a hook_form_alter? Then image.module implements it, and so does your module. (And perhaps others, who knows?)
Comment #67
dman CreditAttribution: dman commentedGood thoughts. I hadn't got that far ahead.
The history of this thing (heh, a year old this month) started off as an attempt to do something that worked but did not need code changes to either other modules. I guess I didn't get out of that mindset enough.
You are totally right that if image.module image processing is to allow 3rd party operations, then the form options should have that extensibility built in. The stupid things I've had to do via form alter could be chopped back down to three lines. Or rather, as you say, just an info hook.
obvious, thankyou. I'll have a look at that.
Comment #68
mafioso CreditAttribution: mafioso commentedsubscribe
Comment #70
pvhee CreditAttribution: pvhee commentedsubscribe
Comment #71
asb CreditAttribution: asb commentedI lost Imagecache integration when "upgrading" from image module 5.x-2.0-alpha3 to 6.x-1.0-alpha4 and would like to get it back. subscribing ;)
Greetings, -asb
Comment #72
dman CreditAttribution: dman commentedI've got an updated stream of this function available at
http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/dman/imagec...
I use this. You can keep up with this if you like. It works. So far. :-/
Comment #73
PlayfulWolf CreditAttribution: PlayfulWolf commentedcan anyone at last combine this peace of code into these modules???
Comment #74
Drupalized CreditAttribution: Drupalized commentedsubscribe
Comment #75
tevih CreditAttribution: tevih commentedsubscribe
and are people trying to make this work for both D6 and D5? I'm on 5.
Comment #76
Drupalized CreditAttribution: Drupalized commented@tevih i'm here for Drupal 6 and this issue also assigned to 6.x-1.x-dev
Comment #77
joachim CreditAttribution: joachim commented@tevih New features are implemented on D6. Once that is done, we can think about a backport.
Comment #78
asb CreditAttribution: asb commented@joachim, @tevih:
> New features are implemented on D6. Once that is done, we can think about a backport.
I'm getting very confused. The functionality dman is developing for D6 (integrating imagecache presets into the image module) exists for D5 for quite a while, at least I have a sub-module "ImageCache 4 Image" running in version 5.x-2.4 that works pretty well; according to /admin/build/modules, that module belongs ImageCache (does it? 437966). So I don't quite understand why it would be necessary to backport this (very cool!) feature since it seems to already exist...
A second thing I don't understand is the relation of the (latest) 5.x-2.0-alpha3 branch to the (latest) 6.x-1.0-alpha4 branch; if new features are developed for D6, I don't understand how this branch (with more features than the 5.x-1.x branches) came into existence; as far as I can see on my D6 sites, stuff like Image Galleries through views does not exist in the 6.x-1.0 branch yet while it is working quite nicely in the 5.x-2.0 branch already.
Sorry, but I'm really confused about this...
@dman:
I tried the imagecache_image module together with ImageAPI 6.x-1.6, ImageCache 6.x-2.0-beta9, and Image 6.x-1.0-alpha4:
Parts of the patch are rejected:
However, the Imagecache intregration appears to work quite well.
What can we do to get this into an official/packaged release, either inside the image module's contribs or as separate project?
Greetings, -asb
Comment #79
joachim CreditAttribution: joachim commented@asb:
- I don't know all the details of the feature in question here. Policy is to develop on the most recent version first. If something already works on 5 then great.
- about the branches: drewish began working on the 5-2 branch before Drupal 6 was released. I contributed the views stuff for image gallery. Then Drupal 6 was released, it took a long time for Views 2 to be released, and it took me a long time to get image support into galleries. There is now a patch for this by the way :)
Comment #80
joachim CreditAttribution: joachim commentedI would say what needs to be done for this to be included is just the changes outlined in #66.
I don't know if this module is best kept as a contrib in image or imagecache, but I'm happy to have it here. Let's see what the other maintainer thinks :)
Comment #81
dman CreditAttribution: dman commented@asb thanks for the feedback.
I imagine image.module may have changed a little bit there in the last month. I'd advise you try to apply those missing lines by hand, because it does eventually have a pointless side-effect of not allowing you to route image derivatives through imagecache if you don't also add a (useless) dimension to the UI. This issue has popped up repeatedly in trying to keep up.
I think that postponing it all until D7 will be disappointing. The thing is, First we need both image.module and imagecache.module to be stable on D7 - then I could look at bridging the gap again. Because neither image.module or imagecache.module currently 'owns' this bridge, it's always falling through the cracks.
The patch I've put in there could, I guess be proposed for image.module D7. It is deliberately and carefully non-invasive, and just opens up a bit of room for this callback.
BUT
Yeah, this is a bit of a Catch-22.
Either I propose it to D7 with no test case or proof-of-concept. Unlikely?
Or we maybe eventually look at it again after imagecache goes stable on D7. :-C
If I thought there was a chance of this happening, then I'd be suggesting that image.module derivative building be reworked quite a bit to support this abstraction natively (and treat its own scale functions as callbacks alongside our new ones). But I don't know if that would be popular or possible.
Comment #82
scroogie CreditAttribution: scroogie commentedI thought that imagecache (API) is going to core in D7?
Comment #83
BartVG CreditAttribution: BartVG commentedreply to http://drupal.org/node/231622#comment-857078
Apart from this transparancy, what's the use of creating static derivatives through ImageCache? I thought that ImageCache was all about generating derivatives on the fly and thus removing the clutter of having an_image.preview.jpg, an_image.thumb. jpg, an_image.blablabla.jpg, an_image.so_and_so.jpg, etc.
When I came across this issue, I thought that this would finally suit my needs, i.e. using Image module (+ Image Gallery and Image Assist) but with dynamically generated derivatives from ImageCache.
Alas...
Are there any objections to this idea? Would it be so difficult to alter all the Image dependent modules to use ImageCache?
Quick idea: route the requests for a certain file to a function that determines whether to take a file from disk or to generate a derivative.
I don't know the inner workings of ImageCache or the Image module, so this piece of code may utterly useless.
Comment #84
freddyseubert CreditAttribution: freddyseubert commented+1 for imagecache_image
just subscribing.
Comment #85
vhenninot CreditAttribution: vhenninot commentedHello,
I would like to use imagecache 4 image, but i don't know how to patch original image module file with image-operations_hook-20090419.patch !
I understand that we have to modify these files by hand :
modules/image/image.admin.inc
modules/image/image.module
modules/image/contrib/image_import/image_import.pages.inc
But i'm not familiar with diff files found here http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/dman/imagec......
=> have i to remove line with "-" and add line with "+" ?
I will try that... and post here again...
Regards,
Vincent
Comment #86
vhenninot CreditAttribution: vhenninot commentedOK, Great !
Work just perfectly !
but no file created in imagecache subfolder...
is it normal because file creation is handled by image module ?
Vincent
Comment #87
vhenninot CreditAttribution: vhenninot commentedWorking BUT not for original image !
I created 3 presets for original (resize to 1280pixels if image is larger than that), preview and thumbnail.
Preview and thumbnail images are successfuly created, but NOT the original one !
I have the original image file i uploaded, but not the "original" file that imagecache should create with my original "preset"...
Could anybody help me with that problem ?
Regards,
Vincent
Comment #88
dman CreditAttribution: dman commented#1 - in order to integrate correctly with assumptions all other modules (like lightbox, and image itself) make about presets - the derivative image is saved in the normal place images/imagename.preview.jpg - not in the imagecache directory.
#2 'original' means always original. It is never modified. The UI should probably take care to disable that option and make it clear that changes will not apply to the original.
Comment #89
vhenninot CreditAttribution: vhenninot commentedHello and thanks for your answer !
For #2 the drupal image module original behavior was to scale to height x weight fixed in the "original" image "label".
with that behavio it is possible tu upload uge image file but to scale and autorotate them to "normal 1280x1024" resolution...
So question is HOW could we handle original image file ?
We could not use original image moodule scale because it does not recognize EXIF, and don't autorotate files...
(autorotate with imagecache action in dev module)
Thanks again for your quick answer,
Regards,
Vincent
Comment #90
dman CreditAttribution: dman commentedReally? Something must have changed since I last looked. I thought original was retained absolutely, because when next re-generating the derivatives, we don't want to be starting from an already-mogrified source.
(Bad things happen if you watermark your 'original' and then generate a watermarked 'preview' from that)
In your case, I'd create a 1280px 'screensize' derivative, and use that where you were previously using _original.
I'm not sure that the code should be changed to modify the 'original' - I see serious data loss possible if you do that. Imagine what would happen if you scaled the 'original' to 50% :-}
Comment #91
vhenninot CreditAttribution: vhenninot commentedYou can see just above the image size boxes : Note: 'Original' dimensions will only be used to resize images when they are first uploaded. Existing originals will not be modified.
The original image is modified if we put values in height and weight !
My Goal is to prevent keeping too big jpg files... that why i want to downscale image (if necessary)
The only solution is use original drupal image sacle... but then loosing autorotate... not possible...
AAAhhhhh !!
:o(
Thanks for your help !
Regards,
Vincent
Comment #92
vhenninot CreditAttribution: vhenninot commenteddman, if you know, how to disable the UI check, or just know where to search... tell me !
Because with autorotate it is more important to use the first derivative rotate correctly than the original !
Vincent
Comment #93
vhenninot CreditAttribution: vhenninot commentedI think it could be here, in image.module :
$all_sizes = image_get_sizes(NULL, $image_info['height'] / $image_info['width']);
foreach ($all_sizes as $key => $size) {
// We don't want to include the original.
if ($key == IMAGE_ORIGINAL) {
continue;
...
Vincent
Comment #94
marcus178 CreditAttribution: marcus178 commentedI was look to apply this patch to 6.x-1.0-beta3 but assuming that won't work as the code seems to be all different. Is that correct?
Comment #95
joachim CreditAttribution: joachim commentedI confess I no longer have any idea what this issue is doing.
I wonder whether the best thing would be to work in a new 6.x branch on the conversion of image module to be a simple wrapper for imagefield+imagecache. This would mean an upgrade script to convert all image data to CCK and the preset data to imagecache.
Comment #96
scroogie CreditAttribution: scroogie commentedPerhaps that would be a good idea. It could also have a successor to image_attach through filefield_sources, with optional integration of img_assist/imagebrowser, or a successor for image_gallery either taxonomy- or views-based.
Comment #97
Scott J CreditAttribution: Scott J commentedI think that this is a great idea. Please start a 6.x-3.x as soon as possible. It seems that the conversion scripts have already been written, such as http://drupal.org/node/432860 and http://drupal.org/node/201983, so why not make it official?
A new branch would then give direction to the dozen or so other modules that depend on Image, so that they can upgrade in an orderly manner. I see that someone has already forked img_assist module on their own, to become imagefield_assist; this has got to be a bad thing in the already confused state of Drupal image support.
With Drupal 7 on the horizon, it becomes all the more important for Image to be all tidied up and 'standardised' ready for more conversion at that point. And just think, your support queue should be much shorter for a wrapper/helper/glue module, as problems can just be reassigned up to the parent modules!
Image module has withstood the test of time, proving that a lot of people find it useful to have a single integrated, all-in-one place to go for images, attachments and galleries, so I would hate to see it lose momentum now by people looking for a 'more modern' or standard/cck method for their sites.
Comment #99
grub3 CreditAttribution: grub3 commentedI would love to have this patch.
Comment #100
David Stosik CreditAttribution: David Stosik commentedSubscribing. :)
Comment #101
ManyNancy CreditAttribution: ManyNancy commentedSubscribe
Comment #102
panhead490 CreditAttribution: panhead490 commentedSubscribe
Comment #103
joachim CreditAttribution: joachim commentedFor reference, here's what I explained to panhead on IRC just now about what I meant in comment #66 above:
[21:32] joachim_: what I mean is create a new hook
[21:32] joachim_: same idea as something like hook_node_info
[21:33] joachim_: it merely asks modules "what image operations do you provide?"
[21:33] joachim_: image module would then say 'scale, crop'
[21:33] joachim_: this new module in the patch would say 'I have all these shiny imagecache presets'
[21:33] joachim_: the form would invoke the hook to discover the possible presets and use that data to populate the dropdown
[21:34] joachim_: the hook would need to return: name, label, some sort of callback so image module knows how to make it happen, and as we've seen, whether you want x*y imension fields
[21:35] joachim_: so it does involve ripping up a chunk of image.module
Comment #104
dman CreditAttribution: dman commentedRevisiting.
image.module DRUPAL-6--1 (dev) http://drupal.org/node/94674 April 22, 2010
imagecache.module DRUPAL-6--2 (dev) http://drupal.org/node/96391 2010-May-30
The patch looks a little big, but it's mostly modifications to the UI, changing the validation rules to let through the new options, and a large amount of inline documentation, so it becomes its own API docs.
I modified image.module to actually publish and invoke its OWN scale and scale_crop actions using the same methods, which was slightly abstract, BUT it means that everyone uses the same process now. Image.module stil works just fine without imagecache, it just talks to itself through the new hook_image_operations()
Thanks to panhead490 for providing me motivation to do this again - properly this time!
I found 70 coder style errors pre-existing in image.module -dev which I'd like to tidy up also if I'm allowed, but I'll not do that until someone can review and let me know if my hooks etc I'm inserting have a chance of being accepted...
Here's the juice, the hook and the callback image.module now use to build images:
This method now replaces the 'switch' that was in the middle of _image_build_derivatives()
I think I've worked through all the issues I encountered last time with the validation complaining sometimes when the image settings form was being submitted. AND I added in proper support for rebuilds, so that changes in a preset will propogate back to the derivatives saved elswhere.
:-)
Share and enjoy!
Or at least review!
Comment #106
joachim CreditAttribution: joachim commented> I found 70 coder style errors pre-existing in image.module -dev which I'd like to tidy up also if I'm allowed
In haste, just seen this as about to leave... don't include extra tidying up in a patch; it makes it much much harder to review.
Comment #107
dman CreditAttribution: dman commentedI probably built those patches from the wrong directory (above the actual module). :(
Not sure what the bot thinks about applying patches to a module that's different from the queue ;-)
I'll try again, but I think I need to go find the testbot instructions ...
Comment #108
dman CreditAttribution: dman commented"don't include extra tidying up in a patch"
Certainly not - this one is scary enough already!
But it wasn't until I was done that I ran the review and noticed :-)
I'll commit to fixing that for us immediately next ... if you can look favorably on this initiative ;-)
It got a bit stalled last time hanging in limbo between the two modules both in active development. It doesn't make a lot of sense unless we can get this bridge into BOTH projects at once.
Deal?
Comment #109
joachim CreditAttribution: joachim commentedDoes this need work to happen on imagecache too?
Comment #110
dman CreditAttribution: dman commentedYes, that's the second patch file.
One makes image.module use hooks, another makes imagecache invoke said hook.
Comment #111
joachim CreditAttribution: joachim commentedI reckon you can put that in imagecache_image and add that as a contrib module here.
Comment #112
dman CreditAttribution: dman commented95%, yes, true.
It would certainly be more convenient to have it all in one project.
The one thing it's missing is a way to notify image.module that the imagecache preset has been changed and thus the derivative needs a rebuild.
There's no hook in imagecache to catch that.
Previously I added a #submit action with form_alter to catch when an imagecache preset was being saved, but that still had some holes. I need to capture the imagecache 'flush preset' event.
If I can just get that in - it would require abstracting a little bit more - to imagecache, then yes, I'd love for the bridge functionality to live in one place. We failed to find a home for it last time I tried...
I was also thinking of making the integration optional - but it only made sense if making it optional from the imagecache side. The things needed to do to image.module were so much in the middle of things (but only adding hooks) that turning off hook functionality was no win.
So ... if the remaining bits lived an imagecache-bridge within image.module .. that could work, yeah.
Comment #113
AntiNSA CreditAttribution: AntiNSA commentedsubscribe
Comment #114
izmeez CreditAttribution: izmeez commentedsubscribing
Comment #115
hswong3i CreditAttribution: hswong3i commentedsubscribing
Comment #116
joachim CreditAttribution: joachim commentedIt's going to be a few weeks before I have enough time and a clear enough head to properly review this, but here is a very quick review just from a read of the code:
- rather than call the hook again to get $our_operations, I would add a key to what the hook returns, like:
'needs_dimensions' => TRUE,
It's unlikely that any other module implementing this hook would need dimensions too... but it makes the code that little bit smoother, as you just test that value when you iterate the operations to see whether to build the height and width form elements.
(We could even have each operation specify names of form elements it wants, and therefore hypothetically allow other hooks to say they want a text field there, but I think this is overly complex and is never going to be used!)
Similarly in the validation handler, there's probably no need to call the hook again to see which operations need those values checking -- just look in $form to see if that operation has those in the first place.
_image_build_derivative() vs _image_build_derivative() -- avoid having two function names differ by a plural like the plague! it makes code harder to read, trips you up unless you've noticed both exist, and is an invitation to make typos.
Also:
> + * CHANGELOG - this was using $form[...]['#value'] where it should have been
+ * using $form_state['values']. Changed it to behave normally, but unsure if the
+ * previous method was intentional. - dman
I've a feeling that's D5 code that never got updated. Could someone file an issue with this and check in old FormAPI docs if that's the case? We should fix this as a separate patch.
Comment #117
dman CreditAttribution: dman commentedyeah, it was a bit of an assumption.
I can't see any 'other' module being able to couple any closer than this either, but at least a flag would remove any assumptions.
I had pains with the validator getting in the way every time I tried this sort of patch (2 years and counting now I think). The extra check may be overkill or left over from a different version.
_image_build_derivative() - I'll need to revisit what was happening there. Point taken, but there was a reason.
I think we can discard the old $form[...]['#value']. It looked like a left-over.
Comment #118
joachim CreditAttribution: joachim commented> at least a flag would remove any assumptions.
It's more about making the code simpler and easier to read :D
> I think we can discard the old $form[...]['#value']. It looked like a left-over.
I think so too, but I'd prefer this got fixed in its own issue.
Comment #119
a_d_jackson CreditAttribution: a_d_jackson commentedimagecache_imagesize_integration.patch queued for re-testing.
Comment #120
joachim CreditAttribution: joachim commentedNo, it needs work. The current patch has already passed tests.
Comment #121
dman CreditAttribution: dman commentedIf that minor code style repair is a blocker, here's a new issue for it.
#841680: image_admin_settings_validate() was inspecting $form[...]['#value'] inappropriately
So this issue is now pending that one.
Comment #122
joachim CreditAttribution: joachim commentedThanks for filing that and rolling the separate patch. I've committed that fix.
Comment #123
ElGringo CreditAttribution: ElGringo commented#104: imagecache.image_integration.20100604.patch queued for re-testing.
Comment #124
MBroberg CreditAttribution: MBroberg commentedsubscribe
- for people just joining this 2-year thread, do we have any (semi)working code, and do we apply it to both modules? This is so needed - thank you!
Comment #125
MBroberg CreditAttribution: MBroberg commentedoops sorry, I did not mean to change any status
Comment #126
joachim CreditAttribution: joachim commentedAFAIK the patch needs work because we fixed a problem in another issue, and also for the other things I mentioned in comment #116.
Comment #127
dman CreditAttribution: dman commentedRight. So now that's through I should try a re-roll :-)
I'll give it a go again.
Comment #128
dman CreditAttribution: dman commentedHere's a re-roll of #107.
Revised as per joachims comments #116
There is no more _image_build_derivative(s) confusion. Now the two callback stubs
_image_build_derivative_scale()
_image_build_derivative_scale_and_crop()
are not crammed into one switch statement, they are individual, small callbacks.
Even when I was first doing it, I was tempted to abstract the 'dimensions' form elements into a callback or FAPI snippet to allow different presets to put different settings there ... but I agree that will be unused, and would mean messing with the layout more than I want to. Plus I'd need to put the validation into smaller callbacks and get messy. So we'll still just have the base actions with either a setting that has dimensions and 'others'. Using the flag as suggested.
For the validation handler, just inspecting whether the form element exists, without first checking whether the form element should exist (by retrieving the operation definitions first) seems like pretty weak validation. But I'll try it, using both isset() and empty().
... and ... no, actually that can't work. It makes it impossible to switch between operations that do and don't require dimensions.
I NEED to look at the submitted requested operation['needs_dimensions'] before deciding whether height x width needs validation.
... dammit. Now I can't switch back either. The form doesn't rebuild to adjust to conditional validation requirements if I throw an error first. I also tried shifting the individual rows validation into an element_validate callback but found the same problem.
- so this current version has a small gap in the validation if you switch from a third-party preset back to an image.module operation - it allows you to do so without immediately forcing you to enter new valid dimensions.
If anyone can suggest how to do conditional FAPI validation with required fields that come and go I want to know, I searched for an hour but couldn't do it.
Against todays DRUPAL-6--1 -dev.
Results from applying this patch should be entirely transparent. You'll see no difference in behavior at first.
To make the changes work, we also need the second patch in imagecache itself that will advertise the extra options that will then become available in the image settings. I'll attach the patch but as it applies to imagecache project (also todays dev, DRUPAL-6--2), it will probably fail against testbot here.
When BOTH patches are applied, we get the UI changes illustrated in #104
Comment #130
dman CreditAttribution: dman commentedsecond failure as expected. Only the first one counts for this module
Comment #131
joachim CreditAttribution: joachim commentedWow. I'm impressed -- within moments of applying these patches I had a desaturated photo showing in my image node!
Now for the detail...
Too many @s in here. They're odd and scary, and as much as I hate how wordy PHP gets with endless checks to isset() and empty(), we should use those.
Here, I assume we're allowing for the fact that there might not be an operation for the current form element, in the event that a module has been uninstalled?
In which case, we can test for that in the else just above -- I've made that change in my version of the patch.
No need for the scary @ -- the size key is always set, just it may be an empty string. Changed that in my patch.
This is scary too.
Can we expand this, or wrap in a test on ['needs_dimensions'] ?
Why don't we just change the signature of image_scale() and use it directly?
Ditto scale and crop.
- return FALSE;
+ //return FALSE;
+ // One failure may not mean that we should give up entirely. Make the other derivatives anyway.
Just kill the return line if it's not needed, though having the comment to explain what we're doing is good.
+ $operations = module_invoke_all('image_operations', TRUE);
What's the TRUE for?
> - so this current version has a small gap in the validation if you switch from a third-party preset back to an image.module operation - it allows you to do so without immediately forcing you to enter new valid dimensions.
Ah, yes, I see what you mean. This is where ideally we'd have the widthxheight portion of the form AJAX itself in. Which I doubt anyone has time to implement, so I'm happy to leave it as is.
Also, the doc header for image_image_operations() needs some work -- probably put the array details in the actual @return bit -- but it's breakfast time here :)
Comment #132
dman CreditAttribution: dman commentedWell at least it worked!!
@s are a bit of a concern, but in this case they are mainly there for legacy/upgrade smoothness. First install of this version onto a running site would complain until you'd saved the settings once. I always run with E_ALL (as you can guess) and I've spent swathes of my Drupal time eliminating warnings in contrib.
In this case it's a conscious choice - I fully expect some indexes to be undefined sometimes and that's OK and @ is just succinct.
But yeah, we can add another handful of isset()s around the place, just to be really thingy about it.
It was complaining during dev for me... $size['height'] can be undefined if switching back from an external operation. But a really trivial notice if so, so I ignored it quickly.
Yeah I looked at that. reason: because it's core. includes/image.inc. Not gonna go there.
+ //return FALSE;
Sorta debug FYI. I was about to del it then thought the comment was left out of context, so hesitated. Just cruft now.
I've encountered a number of reasons imagecache processes can fail, so I've tried to deal with that case.
An earlier iteration had image_operations returning a pre-filtered list of just the form-select option array. I retired that idea, that must be a left-over we can remove.
I was floating on the fringe of going AJAXy with this, but it meant too much surgery on the current form. For very limited utility (and still validation pain). So we'll live with it.
True. The docblock and API definition floated around between various files as it developed. Never quite found the right home for it. Has been a work in progress. I think we are supposed to add an image.api file to declare and document it or something, but that seemed a bit of a reach for now.
Comment #133
joachim CreditAttribution: joachim commented> But yeah, we can add another handful of isset()s around the place, just to be really thingy about it.
I think isset()s are the best of two bad options.
> Yeah I looked at that. reason: because it's core. includes/image.inc. Not gonna go there.
Oops. I acked it in the code and thought I saw it defined in the module.
Having two functions that are mere wrappers seems a bit wasteful. If you want to switch back to a single wrapper that switches, I'm fine with that -- it was just the actual name of the function I didn't like.
> Sorta debug FYI.
:D
> I was floating on the fringe of going AJAXy with this, but it meant too much surgery on the current form.
Yeah. Let's leave it, and if someone wants to have a go implementing some basic form ajax, they can tackle it in a subsequent patch. The gain in functionality here is definitely worth a minor UI glitch.
> True. The docblock and API definition floated around between various files as it developed.
An image.api file is part of the spec for D7. Not needed here yet.
What I meant is that the array you return should be laid out in the actual @return thingy. Look at http://api.drupal.org/api/function/hook_menu for an example.
Comment #134
dman CreditAttribution: dman commentedI'm well in favor of some isset()s. Was just looking for some shorthand to make the patch less intimidating really.
... The code actually ended up more concise with two trivial stubs! And it's marginally better-practice (not overloading one stub) and a better illustration of the way the API works. So I'm pleased with this alternative. Coming back to it after a week/month showed me there was no compelling reason to scrunch them together.
I'll get your patch down and see if I can over-document the docblock. (I'm way too wordy sometimes)
Comment #135
joachim CreditAttribution: joachim commented> Coming back to it after a week/month showed me there was no compelling reason to scrunch them together.
Ok let's keep that as two stubs then.
Comment #136
sunThe previous code rightfully tested values that have been submitted; the new code checks already stored values.
Trailing white-space and comments exceeding 80 chars here and elsewhere in this patch.
Error suppression is slow and poor code. Here, the inner foreach can be wrapped into a condition with two isset()s.
See http://drupal.org/node/1354 for formatting standards for lists.
Two watchdog messages will be fired here.
The return is required to prevent PHP warnings for attempting to work with a non-existing file.
Powered by Dreditor.
Comment #137
dman CreditAttribution: dman commentedI don't see what you mean.
...
...
That is checking the submitted $form_state['values'] - as intended. It just unpacked it a little more than before.
I may be missing something.
Long comments, yeah. Can chop them out if they are getting in the way. Long comments now multi-line
@error suppression discussed above. We are free to add isset() instead. May make for some long lines.
becomes
(ugh) but done I feel that might not be quite as logically good though... also need the case if one is not set then there is no match so it should be rebuilt?
docblock formatting discussed above. Can be improved indeed.
reformatted although my IDE (Eclipse) really doesn't like to let me do that layout without 'correcting' it :-/
Hm. Is getting two related warnings a huge error?
'operation' may only be blank during the upgrade? If ever. May need to add an update step to ensure the presets are re-saved at least once. Probably just verbose paranoia though.
OK, added an extra 'else' to avoid the second message on first failure.. Cross fingers that situation never arises I guess.
Hm. Should error-checking be added elsewhere to prevent that possibility closer to the point-of-failure then? I feel error recovery is more robust than immediately giving up.
I think I need to purposely break a few things and create a test case where that will happen. Not sure about that for now.
Patch here, based on joachims #131, with above tasks addressed.
(pre-existing white-space and other code review issues are still endemic throughout the current module, cleanup will be a separate task, as suggested in #106.)
Comment #138
riversidekid CreditAttribution: riversidekid commentedsubscribe
Comment #139
chandrabhan CreditAttribution: chandrabhan commentedsubbing for updates
Comment #140
PMorris CreditAttribution: PMorris commented#137: image.imagecache_integration-20100715.patch queued for re-testing.
Comment #142
PMorris CreditAttribution: PMorris commentedI think this patch doesn't work anymore? I got 1 out of 3 hunks FAILED when I tried to apply to the latest development release.
Comment #143
joachim CreditAttribution: joachim commentedThat is most probably because of the code clean-up patch that was committed last week.
Can someone reroll this?
Comment #144
Poieo CreditAttribution: Poieo commentedSubscribing...
Comment #145
BEfH CreditAttribution: BEfH commentedIs there a chance that this issue will get into the 1.0 release of image?
by the way - Great work so far!
Comment #146
joachim CreditAttribution: joachim commented@145 see #143.
Comment #147
dman CreditAttribution: dman commentedre-roll. Still works for me
Comment #148
onyxnz CreditAttribution: onyxnz commentedHey dman! Just applied patch #147, but not getting any change in the module's ui. No other options for image manipulation.
Ran the update.php. Also deselected Image module, then reapplied. Any ideas?
Comment #149
dman CreditAttribution: dman commentedsee http://drupal.org/node/231622#comment-3199192
You need to patch BOTH image (to support the change) and imagecache (to publish the change) before you'll see results.
This is part of the problem and why this is taking years to get in. The two modules become interdependent. Well, no actually dependent, but the patch does nothing until BOTH modules are patched up. The good news is that both patches have no negative side effects. The bad news is that neither has any positive effect unless both happen.
This issue is swapping between projects, as the testbot can't do this two-module testing either.
In short, you need #147 on image, AND http://drupal.org/files/issues/imagecache.image_integration-20100714.patch for imagecache.
Comment #150
onyxnz CreditAttribution: onyxnz commentedThanks Dman! works for me now :D
Comment #151
dman CreditAttribution: dman commentedGroovy! Good to hear
Comment #152
AntiNSA CreditAttribution: AntiNSA commentedQuestion.. .I am using feeds to import feeds and find that the images imported and inclued in the the body of the teaser are breaking my layout because they are too big.is this something that you think that can correct this issue?
Thanks!
Comment #153
dman CreditAttribution: dman commentedWell, not this.
But my sandbox project:image_ownage addresses this sort of problem.
help (no embedded images in the CVS viewer, sorry, but it's in the module)
... though maybe not with additional preset processing. I can't recall just now, though it probably needed to try to do that...
Comment #154
AntiNSA CreditAttribution: AntiNSA commentedawsome. does your image ownage have a project/module drupal project page?
Comment #155
joachim CreditAttribution: joachim commentedPatch applies and looks good.
Great work, dman. Thanks for all your hard work and persistence on this! :D
I'm going to commit this when I have a spare moment.
I'd like to rework a few of the comments (just nitpicking ;).
If anyone wants to reroll this to remove all the trailing whitespace that would be a huge help.
Further testing of this patch would be appreciated too!
Comment #156
dman CreditAttribution: dman commented@AntiNSA No project yet. Maybe sometime later. insert.module came along a few months after I did this, so I wanted to re-evaluate how much cross-over this had with that before releasing.
(not much as it turns out)
Anyway, off-topic, this thread is long enough already...
If your testing on this feature worked for you, can you give us a screenshot or small issue report? Thumbs up?
Comment #157
bluegray CreditAttribution: bluegray commentedI have the patches applied to the image and imagecache modules and all seems well.
I am trying to get the module 'Imagecache javascript crop' ( http://drupal.org/project/imagecrop ) to work with my imagecache presets, but it seems to be ignored. I think it might have something to do with a special way the cropped image is called from imagecache. Anyone used the imagecrop module successfully with these patches?
Comment #158
joachim CreditAttribution: joachim commented@bluegray: Thanks for testing these patches :)
Regarding imagecrop, it looks like that module is going in to alter imagecache images itself -- see this on the project page description:
> at which time your custom cropped version will overwrite the default file at that preset's location in the Imagecache filesystem.
Hence like you say, doing 'something special'. Not something we can support over here. That module should really be hooking into imagecache properly, rather than stepping on its toes to overwrite its images.
Comment #159
sunThanks for your hard work on this!
Minor: Trailing white-space and not using available space of 80 chars.
Trailing white-space happens to be all over the place in this patch, so needs to be fixed elsewhere, too.
It is odd that a module has to specify it's own name in the registered operations. We should use module_implements() here and automatically set the 'module' key for each operation.
What means the empty($size['operation'])? The comment only explains the latter condition.
Shouldn't this rather be a hook to invoke? Or what is the typical use-case for 'extra'? (could be stated in the comment)
Not sure whether we need this. Looks like it complicates only and isn't necessary for the essential functionality of this patch.
What means TRUE? Based on the rest of the patch, I guess that's just stale debugging code.
This looks like a wild assumption. I do not really understand the explanation for the "weak validation". I'd expect that defining 'needs_dimensions' will trigger this validation, regardless of whether there is label or any other size property elsewhere.
The additional parenthesis around the last condition is superfluous.
The comment should be above the remarked line, not below.
Hm. I fear that this can easily lead to a performance issue. We've had quite major problems with the rebuilding of image derivatives in the past, mainly caused by needless rebuilds. Most probably, this would have to be a hook.
1) The watchdog message reads a bit lengthy. Can we shorten it up to the point?
2) The code's logic can be heavily simplified here by using the following condition in the first place:
This leads to a single else condition without duplicate code.
Similar to my performance remark above, this makes me a little nervous. As of now, a negative status means that we were not able to generate a derivative, so it does not make sense to try again for any other derivative. We need to retain the possibility of a hard loop cancellation for failures that won't change, regardless of which operation is used.
Lastly, we can only commit this patch if we are 100% sure that all of the current functionality is retained and does not lead to negative or unexpected side effects on existing sites. We also need to take other modules integrating with Image into account, e.g., Image Assist and others, which means they need to be tested manually.
Powered by Dreditor.
Comment #160
joachim CreditAttribution: joachim commentedThanks sun for your very thorough review. Looks like this patch needs a bit more work than I thought :/ and you're right we should leave it to a 1.1 to finally get 1.0 out of the door.
> We also need to take other modules integrating with Image into account, e.g., Image Assist and others, which means they need to be tested manually.
Yup, I hadn't thought of all the modules that depend on image. We're at the base of a pretty large ecosystem.
However, I think the changes we make should be transparent. The derivative files get created in the same place, with the same data being stored, right?
That said, some manual testing by users of various image ecosystem modules would be great. Could people report back here on which modules they've tried?
Finally, just an aside:
> It is odd that a module has to specify it's own name in the registered operations. We should use module_implements() here and automatically set the 'module' key for each operation.
See #890660: add an alternative way of doing module_invoke_all() which sets a 'module' key in the returned info ;)
Comment #161
dman CreditAttribution: dman commentedGah.
Bad whitespace was largely inherited from the original old code (pre cleanup). This particular patch is now approaching three years old. No excuses for it in comments though (though I'd like to blame my IDE)
Yes, to do it totally 100% abstractly, I'd not be special-casing the image.module 'needs dimensions' special behavior at all. In fact, I'd be adding yet another hook to allow modules to define exactly what form elements they want to put into that column.
That - at the time - felt like a pursuit of the perfect over the good, and added complexity that would probably make this patch less approachable (and a few times harder to test).
Given that current behavior is 100% a special-case for image module, leaving a few special cases for image.module in the existing code was the path of least resistance.
empty($size['operation'])
is mostly just to reduce warnings for upgraders. This transparently allows the upgrade path to just keep working without warnings if the 'operation' was unset.Alternatively, this could be in a hook_update instead, that modifies all presets to the new style. Though tidier, that would be several lines longer, and also break expectations of any other module that uses presets (eg, it would invalidate any exportables, patterns or install profiles). So I allow this code to robustly, quietly, self-repair instead.
Similar code style exists in a few places.
OTOH, this problem may have ceased to exist in the last few years the patch has been maturing.
The 'weak' validation arose because strong validation (at the validate phase) would not allow the UI to switch from a preset that required dimensions to one that didn't and vice versa.
It's heavily commented there because I know it's non-perfect, and an alternative algorithm (which I was unable to imagine) may be able to resolve this situation. I could not at the time. Rewrite is welcome.
Needed to test all combinations of saving, re-saving, switching operations, adding or blanking labels. This algorithm is the best I could do when I tried.
// Not one of our own processess, Always rebuild.
Yes, there could some day be an improvement there. Adding another hook - and more to the point - convincing imagecache to tell us whether each image needed to be rebuilt or not was a large undertaking. I can't generically tell if an imagecache derivative really needs a change or not. Updating a watermark logo image, for example - I just couldn't tell whether a rebuild was neccessary. It seemed like I needed to load a history of changes into the imagecache profile just to answer that question.
I left that as a possible room for improvement, nice-to-have - if we could ever get the basic functionality framework in to go forward from.
Point acknowledged, but premature optimization will stall the effort. It will only (maybe) trigger extra performance in folk that are using this new cutting-edge feature. Then we can address it.
The perfect vs the good again. Perfect will take another 3 years.
My watchdog messages do tend to be wordy, yeah. Feel free to reword as you suggest.
In my experience and testing it does (make sense). Basically because complex imagecache actions are more likely to maybe fail than the truly-basic 'resize' options that were available before.
EG, imagecache text action that puts an attribution line on a picture. For whatever reason (a GD upgrade), the ttf font becomes unavailable at a later date. I don't want this relatively minor bug to suddenly mean my site is entirely incapable of showing thumbnails at all.
YMMV, but I put this in because it suited my use-case to gracefully fail rather than die. Besides, I don't see that trying the next process and failing again is anything more awful than slightly preventable. I don't see the distinct advantage in dying early if there is a chance the next phase is just fine.
Indeed, that's been the prime motivator all along - and why some of the code (esp the refresh trigger) had to take extra steps to take this into account.
If I'd changed the behavior of image.module at all - this would never fly. This has always been a drop-in enhancement leaving everyone elses (eg lightbox, img_assist) assumptions in place. At least the assumptions visible about the storage of images.
Not sure about any modules that may call internal image.module functions directly though. I've not seen any myself, but it's conceivable.
In order to make this at all palatable/possible/patchable/readable, I've tried to limit it to just 'adding hooks in strategic places' to build from. Leaving the base module still working as much as possible in the old way. Adding the optimizations and nice-to-haves I saw, but had to defer, the 'patch' gets bigger and bigger. I'm trying to move from one working stable point to another working stable point. The perfect future point may be a few revisions further on.
Anyone who can improve on my code is welcome to give it a go! Please, I need help here!
Comment #162
dman CreditAttribution: dman commentedre-roll against DEV, with points in 159 addressed.
empty($size['operation'])
) Seeing as that extra code apparently confuses things (and would indeed become legacy), and rather than debate it, I removed that robustness. Now anyone trying to apply this patch on a live site must visit and save the image presets page at least once. Maybe this can also be done with a hook_update, though I was hoping to avoid adding new code there.If there is a way to trigger form rebuild in the validation phase, I haven't found it, it seems like form_set_error means we get a cached form instead.
Comment #163
dman CreditAttribution: dman commentedtestbot - go!
Comment #164
joachim CreditAttribution: joachim commented> Now anyone trying to apply this patch on a live site must visit and save the image presets page at least once. Maybe this can also be done with a hook_update,
Sounds to me like it could, and it's what hook_update is for.
> I usually put checkpoint statements "If we've got here, this must be the case" inside the conditional for easier scanning
I can't remember what Drupal code standards say on this. Check! If there's nothing stated about this, file a bug :)
this is going to be too late for the 1.0, as we'd really have to roll another beta to get it widely tested. So what I think is best to do at this point is release 1.0 (this week, as soon as I get spare moment, as the minor bug reports seem to have dried up), and then once I've had a proper look at this patch and it's had a bit of testing, commit it to the -dev release and encourage people to try that.
Comment #165
dman CreditAttribution: dman commentedHardly a bug. The standards do say comment before the code, and that's fine.
Comments before an
if
describing the conditional are almost tautologous, as it repeats what is about to be checked.I put a comment inside the if to describe why something is being done then.
..
.. although I see I misread the review note anyway :-)
It was referring to the code snippet above the one I 'fixed'. Confusion reigns. NVM.
I only bumped this today as I was doing a site transfer and minor version upgrade and thought I'd freshen it. If I get really bored I'll try to think of some tests for it. Really bored,
Comment #166
mcaden CreditAttribution: mcaden commentedYes! This really helped.
with the patches applied to dev of both image and imagecache everything seems to be functioning great.
Comment #167
grasmash CreditAttribution: grasmash commented@mcaden: is there also patch that needs to be applied to imagecache for this to work?
UPDATE: yes, I see that I need to also patch imagecache with:
http://drupal.org/files/issues/imagecache.image_integration-20100714.patch
Comment #168
grasmash CreditAttribution: grasmash commented@157 & 158
Ahh.. too bad. I was hoping to do the same thing as bluegray.
Any other way to manually control the crop area via the image module?
UPDATE:
Actually, there is a way to use imagecache presets with the image module without patches. It involves creating a View that manually applies the imagecache preset to the image field (not imagefield). You'll need views customfield.
Create a view and add the relationships "Image:File" and "Image:Node." Then add fields "File:path," "Node->title," and "Customfield: PHP Code." Add this to your php customfield script:
Using this method allows you to use Image Crop to manually select the crop area.
Comment #169
Anonymous (not verified) CreditAttribution: Anonymous commentedFeedback:
Upgraded Image and Imagecache to newest Dev versions
Applied patch in 164 to Image module
Applied patch in 147 to Imagecache module
All working (at present ;) )
Comment #170
joachim CreditAttribution: joachim commented> Now anyone trying to apply this patch on a live site must visit and save the image presets page at least once. Maybe this can also be done with a hook_update,
@dman: Could you explain what you mean by this?
I've just tried applying the patch to an install of image module *without* admin-defined image sizes (or rather, I deleted the image_sizes variable to simulate this ;) and visited the image admin page and all seems fine.
Comment #171
dman CreditAttribution: dman commentednon-fatal.
Just that (I think) that if you have an existing site *with* old image settings saved,
and install the update
but don't visit the admin page after updating
and regenerate some images
- there would be php notices about undefined array indexes triggered, and images might not build at all.
because the image derivative generation would be looking for values that aren't there.
Comment #172
mcaden CreditAttribution: mcaden commented> Now anyone trying to apply this patch on a live site must visit and save the image presets page at least once. Maybe this can also be done with a hook_update,
Just verifying I did have to do this on mine. I hadn't made any new presets, but changed the size for the "preview" image preset. When I went to "Image" there was no dropdown box for anything dealing with imagecache. I clicked "save configuration" and on the next page load, the new dropdowns for imagecache presets were there. I didn't see any errors or anything, there simply wasn't anything dealing with imagecache until I had done so.
Comment #173
dman CreditAttribution: dman commentedSlightly different from what I anticipated ... but yeah, there would be a few hiccups like that if installed on a running site. Non-fatal, but could probably be cleaned up somehow
Comment #174
joachim CreditAttribution: joachim commentedCould someone explain exactly the steps to reproduce the problem? I'm not quite clear on that yet.
Comment #175
mcaden CreditAttribution: mcaden commentedThe one I encountered? It was as predicted in one of the posts above.
Here's the steps I followed and what I encountered:
Steps:
Expected: Imagecache presets would appear as options in the admin page for Image
Actual: No change in the Image Admin
WorkAround:
Comment #176
joachim CreditAttribution: joachim commentedI'm not seeing that problem at all. Admittedly, this is on my test rig which has been kicking around for a while, but didn't yet have imagecache on it.
Steps I took:
1. downloaded and enabled imagecache.
2. patched all modules
3. created some IC presets
4. went to admin/settings/image. IC presets showed as expected.
There's no need to run update.php btw, as neither patch has update functions.
> The one I encountered? It was as predicted in one of the posts above.
Do you know what causes it?
Comment #177
asb CreditAttribution: asb commented@Dan: Have you given up on this issue? What can we do to help?
Comment #178
dman CreditAttribution: dman commentedI thought it was ready to go at #162.
It works just fine, so I haven't had any need to change it.
A requested nice-to-have is an update hook that, um, ensures all your old image settings are re-saved in the new format. As seen in #172. It used to handle that automatically, but the feature was removed in #162 to try and get it accepted.
If anyone wants to try adding it in, that would be easy I guess.
Comment #179
joachim CreditAttribution: joachim commented> A requested nice-to-have is an update hook that, um, ensures all your old image settings are re-saved in the new format.
That's not how I understood it... earlier comments seemed to indicate that right now, applying this patch breaks something. That's no good. If some sort of cleanup or conversion is required, it MUST be provided in an update function.
Thing is, I don't understand what breaks and I've not been able to reproduce it. Can anyone explain this clearly please?
Comment #180
mcaden CreditAttribution: mcaden commentedDidn't break anything for me. All it involved was the extra step in going in and clicking "save configuration" before anything kicked in as dman has mentioned and as I've confirmed.
Comment #181
dman CreditAttribution: dman commentedThe situation *I* anticipate and can replicate is #171.
And the level of potential broken-ness it : that you get a few php notices - If you have error-reporting turned up to 11 like I do (but non-developers don't) - until such time as you've visited the settings page once.
So I find that 'non-fatal'. Indeed, hard to replicate unless you change your php.ini settings, and send errors to the screen, and go looking for it in that window of time.
I only mentioned it because I normally prefer pure php E_STRICT code, and seeing a notice about an undefined index in my log bugged me. Though that's not the way the bulk of contrib works.
You won't even see this logged notice as an error unless you have configured the site as a development machine
It would be tidier to put a fix for it in an update hook. So whoever thinks that squashing an E_ALL level notice that's visible only to paranoid developers on first-run of an upgrade install is worth it can have a go.
As for the second reported issue (new options not turning up immediately) I can't replicate that either, or anticipate why that could happen once the module is enabled. As it apparently doesn't happen once they refresh the screen (and the module doesn't do any caching) then I don't know. Sometimes you do have to refresh a page to see changes.
Heck, maybe an empty hook_update that just tells you to visit update.php would clear the pipes.
Comment #182
joachim CreditAttribution: joachim commented> And the level of potential broken-ness it : that you get a few php notices
Could you tell us what the notices actually are please?
> Heck, maybe an empty hook_update that just tells you to visit update.php would clear the pipes.
If it's just a matter of clearing Drupal's cache, then that's to be expected of module upgrades anyway.
Comment #183
dman CreditAttribution: dman commentedTo replicate :
Step #1 - Use a CVS checkout of D6-dev or
HACK CORE to change includes/common.inc:634 from
to
Ensure that 'error handling' is set to send messages to the screen.
Step #2
Install & enable current dev image.module, unpatched,
use default sizes or modify them if you want.
Upload an image or two.
Step #3
Install and enable imagecache etc.
Apply patch #163 to image, http://drupal.org/files/issues/231622-image-imagecache_integration-20101...
Apply patch #128 to imagecache http://drupal.org/files/issues/imagecache.image_integration-20100714.patch (now offset, but still working)
Step #4
do not visit update.php.
do not go looking at the image size settings.
Create an imagecache preset of some description
Step #5a pre-used dimension settings do not include all the new settings values?
Upload another image, or edit and 'rebuild_derivatives' on one.
I thought I may get a message saying
<code>notice: Undefined index: scale in .../sites/all/modules/image/image.module on line 934.
At least I thought that was possible - I'm actually unable to replicate it now. I don't know, it just isn't reproducable. It was basically caution, described in #171. There is now no actual problem I can see to fix. It was a maybe thing to look for, seems to be OK.
Step #5b Best way to handle the dimensions flag, still not 100% solved.
Visit the image presets settings, you should be able to select the imagecache option and save.
On the first save, you may see the message
notice: Undefined index: needs_dimensions in .../sites/all/modules/image/image.admin.inc on line 97.
Step #5c Missing dependency if you delete the preset or remove the module
Go to modules and disable imagecache and imageapi.
Revisit an image node or an image edit form.
Warnings like
may be displayed, as the tool to generate images is now unavailable.
On the image presets page, you'll similarly see
--------
These sort of warnings were anticipated in #162 when the error-checking code was simplified.
You will not even see these notice level messages unless you have modified your system for development warnings. You have to break your system and go looking for problems before you see these messages that say something is a bit wrong.
This is the only rough edge I know of.
- As for the imagecache preset option not showing up - I still couldn;t replicate that.
Comment #184
joachim CreditAttribution: joachim commentedThanks for that very comprehensive report :)
I think 5a is obsolete -- nowhere is the index 'scale' actually used as an array key in the patch or indeed the entire module or admin files.
5b is solved by changing the offending line to:
This is the D7 way -- doesn't hurt to get used to it now ;)
5c -- it's not just disabling imagecache that will cause this error. You can get it more easily by deleting a preset, and that's something users expect to be able to do without problems.
There's already this code in the imagecache patch:
This will need changing -- for starters, it introduces a silent dependency with the call to image_get_sizes(). But what I would do instead is invoke a hook_imagecache_preset_changed() in various places so you can tell image module's implementation whether this was a change or a deletion.
(aside:
// This is inefficient, but image.module doesn't let us trigger just one
// preset change.
That's something that could be improved in a follow-up patch -- store times per preset.)
Also, I had another look at the patch...
The convention is first person plural -- use 'we'.
This doesn't look right. Yes to not just bailing out. But are those subsequent operations (the chmod, the alter) on the newly generated derivative? If so, those will surely cause problems. I reckon we need a 'continue' here.
Powered by Dreditor.
Comment #185
dman CreditAttribution: dman commentedOr, um,
or it'll find FALSE as TRUE.
70% of my drive-by patches to other contribs recently have been inserting isset() or empty() in strategic places like this. I'm strict about STRICT when I can be.
I think you are right about the
continue
and theimage_get_sizes()
there.Comment #186
joachim CreditAttribution: joachim commentedOh yeah... PHP's empty/isset/is_null always confuses me :/
Comment #187
asb CreditAttribution: asb commented@Dan, @joachim: Again this patch seems to vanish into data nirvana. If I was able to follow this issue, there were a couple of success reports (the patches seem to work), and there were some coding style issues (which were fixed?). So how are the chances to get this into a dev release?
From my (naive) point of view as user it is very hard to understand what problems are left. Thus I'd simply like to remind of two facts:
Thank you!
Comment #188
joachim CreditAttribution: joachim commentedThe problems left -- at least the ones I found -- are outlined in 184 above :)
Comment #189
shady_gun CreditAttribution: shady_gun commentedPatch fails on the latest version of Image(6.x-1.1 ) module ...
Comment #190
Courtney.B CreditAttribution: Courtney.B commentedFound bug (maybe?) with Image after patching with #163 and #128. Not sure if I am supposed to post it here though.
Normally with ImageCache, you use Scale to create a preset if you want to resize using one value only. I made the error of selecting Resize instead of Scale. However, unlike what happened prior to patching, where you couldn't even create a Resize preset with a missing value, it allows you to create it and then when adding other presets, throws a bunch of errors at you.
Removing the faulty Resize preset has fixed the errors and I can proceed as normal.
Seriously, thank you so much for the patches. It was a life saver!
Comment #191
Courtney.B CreditAttribution: Courtney.B commentedEncountered major problem tonight and had to rollback the patches. I receiving a WSOD for pages that used many images and it was due to imagecache regenerating images when there was already an image available.
Comment #192
msbjhandeer CreditAttribution: msbjhandeer commentedimagecache_imagesize_integration.patch queued for re-testing.
Comment #193
joachim CreditAttribution: joachim commentedThis doesn't need testing, it needs work.
Comment #194
AlfTheCat CreditAttribution: AlfTheCat commentedsubscribing
Comment #195
fellow CreditAttribution: fellow commentedI use Imagecache 6.x-2.x and Image 6.x-1.1 and want intergration with imagecache presets for image module. Could you please indicate me if there is any patch that works?
Comment #196
asb CreditAttribution: asb commentedIt seems that nobody sees a future for 'Image' module beyond D7. Considering the age, and activity of this discussion, I'd suggest to "won't fix" it.
Comment #197
joachim CreditAttribution: joachim commentedI think it's more that 'Nobody who needs image module to have a future is able or willing to write the code'.
I do wonder what everyone who's using image on D6 is going to do about upgrading to D7 though :/
At any rate, if someone works on this patch, I'll review and eventually commit it.
Comment #198
asb CreditAttribution: asb commented<cynical>
It's currently just 85,266 'Image' module user that won't qualify as early adopters of D7, or won't qualify as D7 adopters at all ;)</cynical>
However, my Chipin proposal still stands (esp. to resolve the Image Attach issue), as there will come a time where my dozend D6 sites with 'Image' module and together half a million of image nodes want to become migrated. But for now, 'Image' module by far isn't the only showstopper.
Comment #199
AlfTheCat CreditAttribution: AlfTheCat commentedAmen to that, but I'm comfortably in a mental state of denial towards that fact right now. I like being sane too much atm. Life is tough enough.
Comment #200
luco CreditAttribution: luco commentedhey there,
just dropping by to share this link with you folks: http://drupal.org/node/201983#comment-4483072.
hope it helps :] I haven't tested yet, though.
cheers