How to alter image style based on product custom attribute? I'm building a webshop based on Ubercart, and products have a custom attribute "sold out". When this attribute is checked, all product images should be displayed with a semitransparent overlay textbox: SOLD OUT. Theoretically, I found a couple of promising options, but none of them seems to me satisfying:


Using node--product.tpl.php to insert a custom overlay div around the rendered image. This is a very fragile solution, because I cannot put the overlay div inside the main-product-image div. Therefore, it's hard to make it responsive, and on the other hand, cross-browser issues might raise because of the opacity...
Adding a new image style and overriding theme_uc_product_image function. Since style_name is hardcoded here as 'uc_product', it is obvious to override this. But no node array is available here to decide whether to override image_style or not. Maybe a custom sql query?
Manipulating the default uc_product image style from code with hook_image_styles_alter function. Same problem: no node array here.


Any idea?
You could use ImageCache Actions module
and write your PHP field condition right on the generation of the image.

Custom Actions effect is what you need.