I've run into some issues with imagecache derivatives not being generated before I need to use them (for example, if the image is going to be included as an attachment in a mimemail message)
As it currently stands, imagecache generates images when an http request occurs, as opposed to when a link to the cached image is created via theme_imagecache.
As a workaround to the mimemail issue, I was thinking about writing a custom override to theme function, which would hook into imagecache_generate_image to force the generation of the image
But I figure there must be a reason why imagecache doesn't do this already. I would think that it would delay the initial html page load while the cached image was created, which could take some time if there are a lot of images on the page. There might also be some overhead once the images are created, since imagecache_generate_image does some lookup stuff and checks for the file, but not sure how bad of a hit this would be.
But then again, not sure if there are any other work-arounds, other than manually calling imagecache_generate_image for each image in question, which isn't always feasible.
Suggestions?
Thanks!
Comments
Comment #1
sandrewj commentedIf you are using a private filesystem, I don't think there is any disadvantage, since the same basic checks are done in generate_image as in the private filesystem imagecache code. For public filesystems, there is some savings in the current system because drupal code isn't run for image requests after the image is generated.
If you use triggers and filefields, there is an imagecache action to generate all of the derivative images. or you can configure an action to generate only certain presets.
Hope that helps.
Comment #2
rjbrown99 commentedYou may want to check out http://drupal.org/project/imageinfo_cache as it has code to selectively auto-generate specific presets upon initial upload. You can configure which presets are generated per CCK field.
Comment #3
fizk commentedPlease reopen if this is still an issue with ImageCache 6.x-2.0-rc1.