An image field: the picture (an avatar, a logo) in a round or rounded frame, with an edit overlay and a small button to remove or revert it.
<.image_input name="avatar" value={@user.avatar_url} size="lg" />
<.image_input name="logo" value="/images/logo.png" shape="rounded" />With a name the frame is a file picker: clicking the picture opens the chooser, the chosen
file shows at once and the button puts the first picture back or, with nothing chosen, empties
the field and sets the hidden <name>_remove input to 1. The behaviour lives in the
LedgerUI.ImageInput hook (priv/static/ledger_ui/hooks/image_input.js).
Without a name it is only the frame (the design's lu-imgin): initials draws a filled
frame with letters, hover forces the edit overlay and progress draws the upload ring.
Deviations from the README: size has no default (nil is the design's 88px frame with a
large icon, same as md) and shape accepts square (the design's default radius) and
wide too.
Summary
Functions
Renders the image field.
Functions
Renders the image field.
Attributes
id(:string) - Defaults tonil.name(:string) - The name of the file input;<name>_removeis the hidden one. Defaults tonil.value(:string) - The address of the picture it holds now. Defaults tonil.accept(:string) - Defaults to".png,.jpg,.jpeg,.webp".size(:string) - Defaults tonil.Must be one ofnil,"lg","md","sm", or"xl".shape(:string) - Defaults to"circle". Must be one of"circle","rounded","square", or"wide".label(:string) - Defaults to"Choose a picture".remove_label(:string) - Defaults to"Remove or revert the picture".initials(:string) - Letters on a filled frame when there is no picture. Defaults tonil.hover(:boolean) - Draws the edit overlay (the hover state). Defaults tofalse.loop(:string) - Animated demo of a state:hoverloops the edit overlay (m-hover),ringloops the upload ring (m-loop). Defaults tonil. Must be one ofnil,"hover", or"ring".progress(:integer) - An upload ring, 0 to 100. Defaults tonil.disabled(:boolean) - Defaults tofalse.class(:any) - Defaults tonil.- Global attributes are accepted.