Expand description
Not feature-gated, unlike cashier/[db]/[permission]/etc. above:
<Image ...> is core template-directive surface, the same tier as
wire/spa (see spa’s own doc comment for the identical
reasoning). Backs larust-view’s own <Image src="..." width="..." height="..." /> tag - see larust-image’s own doc comment for the
full design (on-demand resize + AVIF/JPEG re-encoding, local images
only).
Structs§
- Image
Options - Every
<Image ...>attribute, one field each - see this crate’s own doc comment for the full meaning of each one. OwnedStrings, not borrowed&strs, deliberately:larust-macros’ own codegen (which constructs this struct literal directly, one field per attribute, no builder calls needed there) hands it a:src="expr"dynamic attribute’s own value exactly as whatever type that expression produces (String,&str, anythingDisplay) - converted uniformly via.to_string()either way - rather than needing a lifetime parameter here just to borrow a value that’s just as often a literal as it is some other owned value computed on the spot.ImageOptions::new/ImageOptions::fillplus the builder-style setters below are for a hand-written Rust call site instead, and acceptimpl Into<String>so a plain&strliteral still needs no extra ceremony there either. - Image
Plugin
Enums§
- Loading
"lazy"(default - load when entering the viewport) or"eager"(load immediately). SeeImageOptions::loading.- Placeholder
Empty(default - nothing shown while loading) orBlur(a cached blur-up thumbnail behind the image). SeeImageOptions::placeholder.
Constants§
- DEFAULT_
QUALITY - Default JPEG/AVIF quality (1-100) when a call site doesn’t pick one -
the same ballpark Next.js’s own default (
75) uses: a real size reduction with no visible artifacting for typical photographic content.
Functions§
- build_
srcset srcset’s own value whensizesis set - one entry per [SRCSET_BREAKPOINTS] (capped atMAX_DIMENSION), each an aspect-ratio-preserving width-only variant (seeoptimized_url’s ownheight: Nonecase) of the same on-demand route the plainsrcalready uses - nothing here is pre-generated; a given breakpoint is decoded/resized/encoded (and cached) only the first time some visitor’s browser actually requests exactly that width.- optimized_
url - The URL
<Image ...>renders into itssrcattribute (or one entry of itssrcset) - your own app never calls this route directly, this is the one real entry point.srcis a path relative topublic/(e.g."images/hero.jpg"for a file atpublic/images/hero.jpg) - percent-encoded here so a path containing spaces or other reserved query-string characters still round-trips correctly.height: Nonerequests an aspect-ratio-preserving resize instead of a fixed box (seeResizeTarget::Width) - used for everyfill/sizes-driven variant, where only a target width is actually known. - tag
- A ready
<img>tag - what<Image ...>actually expands to. See this crate’s own doc comment for the full meaning of everyImageOptionsfield. Takesoptionsby reference - several fields (srcin particular) are read more than once below, andImageOptionsownsStrings rather than borrowing&strs (see that struct’s own doc comment for why), so a by-valueImageOptionswould mean the first read moved a field a later one still needed.