Skip to main content

Image

shadow

The Image element is used to display images. Adds lazyload function to images and displays a placeholder icon (loader) in the form of an animated image during loading.

It uses the Intersection Observer API, so it only loads images when they are visible in the browser window. This reduces network load and improves site performance.

Basic Usage

Fallout

The Fallout attribute specifies the action to be taken in the event of an error when loading the image. Možné hodnoty sú delete (odstráni sa obrázok) alebo log (vypíše chybu do konzoly).

Fallout - Delete (delete)

The fallout attribute with the value "delete" causes the element to be removed if an error occurred while loading the image.

Fallout - Log

The fallout attribute with value "log" causes the element to be removed if an error occurred while loading the image.

Attributes and Properties

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

Events

No events available for this component.

Methods

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 Properties

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

Slots

No slots available for this component.