Skip to content

image class

A control that can display an image.

Methods

__init__()

__init__(
    content=None,
    label=None,
    on_action=None,
    width="300px",
    height=None,
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new image element.

Parameters:

Name Type Description Default
content dynamic(Union[path, URL, file, ReadableBuffer])

The image source.
If a buffer is provided (string, array of bytes...), and in order to prevent the bandwidth to be consumed too much, the way the image data is transferred depends on the data_url_max_size parameter of the application configuration (which is set to 50kB by default):

  • If the size of the buffer is smaller than this setting, then the raw content is generated as a data URL, encoded using base64 (i.e. "data:<mimetype>;base64,<data>").
  • If the size of the buffer is greater than this setting, then it is transferred through a temporary file.

None
label dynamic(str)

The label for this image.

None
on_action Union[str, Callable]

A function or the name of a function that is triggered when the user clicks on the image.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • id (str): the identifier of the button if it has one.
  • payload (dict): a dictionary that contains the key "action" set to the name of the action that triggered this callback.

None
width Union[str, int, float]

The width of the image control, in CSS units.

300px
height Union[str, int, float]

The height of the image control, in CSS units.

None
active dynamic(bool)

Indicates if this element is active.
If False, the element is disabled, and user interaction is not allowed.

True
id str

The identifier assigned to the rendered HTML component.
This can be used in callbacks or to target the element for styling.

None
properties dict[str, Any]

A dictionary of additional properties that can be set to the element.

None
class_name dynamic(str)

A space-separated list of CSS class names to be applied to the generated HTML element.
These classes are added to the default taipy-image class.

None
hover_text dynamic(str)

The text that is displayed when the user hovers over the element.

None