Skip to Content
DataCards 2.2.4 is released 🎉

Image Card

Card type: image

Data type of variable: str (URL of image)

Image card

The image card allows you to display and manage images in your deck.

To upload an image, click the upload button, or drag and drop an image onto the card. The image will be uploaded to the DataCards instance and the connected variable will be set to the URL of the image. Alternatively, the URL can be set programmatically (see example below).

In addition to the common parameters and the input card parameters, the image card has the following configuration options:

NameTypeRequiredDescription
alt_textstrNoAlternative text description for the image.
optionsdictNoObject containing display options.
options.fitstrNoHow the image should fit within its container. Options: 'cover', 'contain', 'fill', 'none', 'scale-down'. See CSS object-fit for more details.
options.opacityfloatNoImage opacity from 0 to 1 (default: 1).
fill_cardboolNoWhen set to True, the image will fill the entire card space including the header area. When False (default), the image will be positioned below the header.

Examples

Basic image card

Ready to upload an image.

datacards.publish.card( type='image', label='Image', alt_text='Image description', options={ 'opacity': 1, 'fit': 'cover', }, logic_view_size=(4,2), variable_key='my_variable_key', fill_card=False )
Image card before upload

Set the URL programmatically

image_url = "https://picsum.photos/200/300" if image_url: datacards.publish.variable("my_variable_key", image_url)
datacards.publish.card( type='image', label='Image', alt_text='Image description', options={ 'opacity': 1, 'fit': 'cover', }, logic_view_size=(4,2), variable_key='my_variable_key', fill_card=False )
Image card with image

Full card image

An image that fills the entire card space, including the header area.

datacards.publish.card( type='image', label='Image', alt_text='Image description', options={ 'opacity': 1, 'fit': 'cover', }, logic_view_size=(4,2), variable_key='my_variable_key', fill_card=True )
Image card with fill card option
Last updated on