When I have required attributes, so no attribute is selected when a product node is loaded, the uc option image is loaded with theme_uc_option_image_no_image().
theme_uc_option_image_no_image() outputs only an img tag.
Then, in the javascript function UCOI.switchImage() there is this code:
} else if (image[0] == null) {
parentImage = $(':not(.uc-option-image-preloaded) > div.uc-option-image-block');
parentImage[0].innerHTML = "<img src=\""+Drupal.settings.basePath+images[oid].derivative+"\" class=\"uc-option-image\">";
}
In the case of theme_uc_option_image_no_image() $(':not(.uc-option-image-preloaded) > div.uc-option-image-block') does not exist in the markup so parentImage[0] is undefined and no image gets added when you select an attribute.
Comments
Comment #1
ben coleman commentedI ran into this recently. Note that you can't just add a '
to what theme_uc_option_image_no_image() returns, as it is also called to put the no_image image in the preloaded images (see theme_uc_option_image_preloadedtheme_uc_option_image_preloaded). The solution is to wrap the div around the call to theme_uc_option_image_no_image() in uc_option_image in theme_uc_option_image_preloaded. The attached patch fixes it.
Comment #2
hargobindReviewed and tested. Without the code, image switching is broken. This patch makes it work.
Comment #3
makbeta commentedI don't think the solution presented is the best one. To fix the root source of the problem you need to modify the theming function itself.
I have used the version of module from this comment https://drupal.org/node/712542#comment-4776218 & the switching works regardless of the markup around the no-image.png image.