Class Img
The img element represents an image in the document. It is a void element that embeds an image into the page. The alt attribute is required for accessibility, providing alternative text for screen readers and when images cannot be displayed.
Examples:
The following convenience methods are provided for constructing instances of this bean:
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionalt attribute.crossorigin(String value) crossorigin attribute.height attribute.ismap attribute.src attribute.usemap attribute.width attribute.Methods inherited from class org.apache.juneau.bean.html5.HtmlElement
accesskey, attr, attrUri, class_, contenteditable, deminimize, dir, getAttr, getAttr, getAttrs, hidden, id, lang, onabort, onblur, oncancel, oncanplay, oncanplaythrough, onchange, onclick, oncuechange, ondblclick, ondurationchange, onemptied, onended, onerror, onfocus, oninput, oninvalid, onkeydown, onkeypress, onkeyup, onload, onloadeddata, onloadedmetadata, onloadstart, onmousedown, onmouseenter, onmouseleave, onmousemove, onmouseout, onmouseover, onmouseup, onmousewheel, onpause, onplay, onplaying, onprogress, onratechange, onreset, onresize, onscroll, onseeked, onseeking, onselect, onshow, onstalled, onsubmit, onsuspend, ontimeupdate, ontoggle, onvolumechange, onwaiting, self, setAttrs, spellcheck, style, tabindex, title, toString, translate
-
Constructor Details
-
Img
public Img()Creates an emptyImgelement. -
Img
Creates anImgelement with the specifiedsrc(Object)attribute.- Parameters:
src- Thesrc(Object)attribute. Can benull , in which case the attribute is stored with anull value (not removed).
-
-
Method Details
-
alt
alt attribute.Specifies alternative text for the image. This text is displayed when the image cannot be loaded and is used by screen readers for accessibility.
The alt text should be descriptive and convey the same information as the image.
- Parameters:
value- Alternative text for the image. Can benull to unset the attribute.- Returns:
- This object.
-
crossorigin
crossorigin attribute.Specifies how the element handles cross-origin requests for CORS (Cross-Origin Resource Sharing).
Possible values:
"anonymous" - Cross-origin requests are made without credentials"use-credentials" - Cross-origin requests include credentials
- Parameters:
value- How to handle cross-origin requests. Can benull to unset the attribute.- Returns:
- This object.
-
height
height attribute.Vertical dimension.
-
ismap
ismap attribute.Whether the image is a server-side image map.
This attribute uses deminimized values:
false - Attribute is not addedtrue - Attribute is added as"ismap" - Other values - Passed through as-is
-
src
src attribute.Address of the resource.
The value can be of any of the following types:
URI,URL,String. Strings must be valid URIs.URIs defined by
UriResolvercan be used for values. -
usemap
usemap attribute.Specifies the name of an image map to use with this image. The value should correspond to the name attribute of a map element that defines clickable areas on the image.
The value should start with "#" followed by the name of the map element.
- Parameters:
value- The name of the image map to use (e.g., "#mymap"). Can benull to unset the attribute.- Returns:
- This object.
-
width
width attribute.Horizontal dimension.
-