Skip to content

ImageResource

Mark Reeves edited this page Jan 4, 2018 · 2 revisions

ImageResource is a specific type of InternalResource which implements Image. An ImageResource represents an image. For web purposes this is generally an image of MIME type image/jpg or image/png but could be any image file. An InternalResource is used when an image is in the Java class path but not in the application.

ImageResource is used by WImage.

ImageResource properties

The description

The ImageResource description is a text description of an image most commonly used to provide the alt attribute content of an img element.

ImageResource pngResource = new ImageResource("/path/to/flag.png", "flag");
pngResource.getDescription(); // returns "flag"

Size

ImageResource size is a java.awt.Dimension which is exposed using getSize().

MIME Type

The MIME type of the underlying image is exposed using getMimeType().

ImageResource pngResource = new ImageResource("/path/to/flag.png", "flag");
pngResource.getMimeType(); // returns "image/png"

Further information

To be continued

Clone this wiki locally