Class Image
- All Implemented Interfaces:
Component
Mutable and not thread-safe. Source and dimensions are retained on this instance. Mutate within a request-scoped flow. For reuse, stop mutating and render as a stable structure with per-request slot/context values.
Security boundary: source URLs are validated to reject javascript: and non-image
data: schemes. Classification trims boundary C0/ASCII space, removes TAB/LF/CR,
and folds ASCII case independently of locale; storage and attribute encoding retain the
original value. Other schemes remain accepted. This is not MIME/payload inspection,
destination authorization, or a guarantee that an image loads safely.
-
Field Summary
Fields inherited from class HtmlTag
attributes, children, id, innerText, innerTextSlot, selfClosing, tagName, trustedHtml -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ImageCreates an image usingImage(String)and its source policy.static ImageCreates an image usingImage(String, String)and its source policy.getAlt()getSrc()getWidth()Alias forHtmlTag.addClass(String).Sets the HTML id attribute for this image.Sets the image source URL.Methods inherited from class HtmlTag
addClass, addStyle, addTrustedStyle, getChildrenStream, getId, hxDelete, hxGet, hxInclude, hxPatch, hxPost, hxPushUrl, hxPut, hxScrollTargetTop, hxSwap, hxTarget, hxTrigger, render, withAttribute, withChild, withInnerText, withInnerText, withMaxWidth, withMinWidth, withUnsafeHtml, withWidth
-
Constructor Details
-
Image
Creates an image using the source policy described onwithSrc(String).- Parameters:
src- original source URL, retained without normalizationalt- alternative text; null becomes empty
-
Image
Creates an image with empty alternative text and the same validated source policy.
-
-
Method Details
-
create
Creates an image usingImage(String, String)and its source policy. -
create
Creates an image usingImage(String)and its source policy. -
getSrc
-
getAlt
-
getWidth
-
getHeight
-
withId
-
withClass
-
withSrc
Sets the image source URL.Security: This method rejects
javascript:URLs and non-imagedata:URLs after boundary C0/ASCII-space trimming, TAB/LF/CR removal, and ASCII case folding for classification only. Data URLs must have the classified prefixdata:image/; payloads and MIME types are not inspected. Other schemes, including custom schemes, remain accepted. Original strings are stored and encoded unchanged; genericwithAttribute("src", ...)does not apply this policy.- Parameters:
src- the image URL or data URL- Returns:
- this Image instance for method chaining
- Throws:
IllegalArgumentException- if src contains a dangerous URL scheme
-
withSize
-