ImageResource in ClientBundle as real <img> element

Refresh

March 2019

Views

467 time

1

The IE9 does not print background images per default. Is there an option to tell ClientBundle, that all images should be real elements not fake css-background images?

1 answers

2

It depends how the ClientBundle is generated, and how the image is constructed from the ImageResource.

By default, ClientBundles' ImageResources are generated as data: URLs for all browsers but IE6 and IE7, which will use sprited images just like an ImageBundle. In IE8 and IE9 though, you have to make sure the appropriate permutation is picked up, because they have compatibility modes that could make them appear like IE6 or IE7. Check the mode that's being used in the IE Developer Tools (hit F12 to open them).

Given an inlined or external ImageResource (one that uses a data: or http:// URL, but not a bundled, AKA sprited image), you can then use the ImageResource's getSafeUri() as the value for the src attribute of an <img> element.
Unfortunately, GWT will unconditionally use a so-called clipped image (the technique used for bundled images, based on a CSS background image) when you pass an ImageResource to Image or AbstractImagePrototype. Let's call that a bug.