ClientBundle中的ImageResource为真正的< img>元件 [英] ImageResource in ClientBundle as real <img> element
问题描述
生成 ClientBundle
,以及如何从 ImageResource
构造图像。
默认情况下为, ClientBundle
s' ImageResource
s被生成为 data:
所有浏览器的URL,但IE6和IE7将使用 sprited images ,就像 ImageBundle
。不过,在IE8和IE9中,您必须确保获取适当的排列,因为它们具有兼容模式,可能会使它们看起来像IE6或IE7。检查IE Developer Tools中使用的模式(点击 F12
打开它们)。
ImageResource
(使用 data:
或 http://
URL,但不是绑定,AKA sprited 图片),则可以使用 ImageResource
的 getSafeUri()
作为 src
< img>
元素的属性。不幸的是,GWT将无条件地使用所谓的裁剪图像当将
ImageResource
传递给 Image $ c>时,基于CSS背景图像用于捆绑 $ c>或 AbstractImagePrototype
。我们称之为bug。
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?
解决方案 It depends how the ClientBundle
is generated, and how the image is constructed from the ImageResource
.
By default, ClientBundle
s' ImageResource
s 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.
这篇关于ClientBundle中的ImageResource为真正的< img>元件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!