Skip to main content

Image

shadow

Element Image slúži na zobrazovanie obrázkov. Pridáva obrázkom funkciu lazyload a počas načítavania zobrazuje zástupnú ikonu (loader) v podobe animovaného obrázka.

Využíva Intersection Observer API, vďaka čomu načítava obrázky iba vtedy, keď sú viditeľné v okne prehliadača. To znižuje sieťové zaťaženie a zlepšuje výkon stránky.

Basic Usage

Fallout

Atribút Fallout určuje akciu, ktorá sa má vykonať v prípade chyby pri načítaní obrázka. Možné hodnoty sú delete (odstráni sa obrázok) alebo log (vypíše chybu do konzoly).

Fallout - Delete (odstrániť)

Atribút fallout s hodnotou "delete" spôsobí odstránenie elementu v prípade, že prišlo k chybe pri načítaní obrázka.

Fallout - Log

Atribút fallout s hodnotou "log" spôsobí odstránenie elementu v prípade, že prišlo k chybe pri načítaní obrázka.

Atribúty a Vlastnosti

alt

DescriptionIt serves as an alternative text to describe the content of the image, which will be displayed if the image is not loaded. It is also used by screen readers.
Attributealt
Typestring
Defaultundefined

src

DescriptionURL of the image. This attribute is mandatory for the <img> element.
Attributesrc
Typestring
Defaultundefined

loader

DescriptionThe URL of the image that will be displayed when the main image is loaded.
Attributeloader
Typestring
Default"./assets/img/image-loader.gif"

fallout

DescriptionSpecifies the action to take in case of an error when loading an image. Possible values are 'delete' (deletes the image) or 'log' (logs the error to the console).
Attributefallout
Typestring | boolean
Defaultfalse

Eventy

No events available for this component.

Metódy

addAction

DescriptionAdds a new action to the internal action object.
Signature(name: string, func: Function) => void

removeAction

DescriptionRemoves the action from the list of actions, if any.
Signature(name: string) => void

deleteImage

DescriptionRemoves the current image by calling the remove method.
Signature() => void

CSS Shadow Parts

NameDescription
nativeRefers to the img element inside the component

CSS Custom Vlastnosti

NameDescription
--wje-img-widthImage width
--wje-img-heightImage height
--wje-img-border-radiusRounding the corners of the image

Sloty

No slots available for this component.