A WImage is a widget that displays an image. The image may be
specified either as a URL, or may be dynamically generated by a
You can set an alternate text using the method
setAlternateText(). The alternate text should provide a
fallback for browsers that do not display an image, and are also
important for accessibility. If no sensible fallback text can be
provided, an empty text is preferred over nonsense.
You may listen to events by attaching event listeners to signals such as
clicked(). Since mouse events pass the coordinates through a
A WMouseEvent object, it is possible to react to clicks in
specific parts of the image.
Image also supports a more structural approach to listening for
events depending on the image location. One can define
interactive areas on the image using addArea(), which
also allows to define a custom tool tip (using
WAbstractArea::setToolTip()) or a different cursor
image (using WAbstractArea::setCursor) for a certain
In contrast to the image, which displays typically a static
image resource, Wt are also includes several options for
dynamically painted graphics.
WImage is an inline widget. The widget corresponds to the HTML
<img> tag and doesn't provide styling. It can be styled
using inline or external CSS as appropriate.