value: Sequence[
np.ndarray | PIL.Image.Image | str | Path | tuple
]
| Callable
| None
value: Sequence[
np.ndarray | PIL.Image.Image | str | Path | tuple
]
| Callable
| None
= None
Initial list of images or videos, or a function to generate them.
file_types: list[str] | None
file_types: list[str] | None
= None
List of allowed file extensions or types for uploads (e.g., ['image', '.mp4']).
label: str | I18nData | None
label: str | I18nData | None
= None
Label displayed above the component.
every: Timer | float | None
every: Timer | float | None
= None
Interval or Timer to refresh `value` if it's a function.
inputs: Component | Sequence[Component] | set[Component] | None
inputs: Component | Sequence[Component] | set[Component] | None
= None
Components used as inputs to recalculate `value` if it's a function.
show_label: bool | None
show_label: bool | None
= None
Whether to display the label.
container: bool
container: bool
= True
Whether to place the component in a padded container.
scale: int | None
scale: int | None
= None
Relative size compared to adjacent components.
min_width: int
min_width: int
= 160
Minimum pixel width of the component.
visible: bool | Literal["hidden"]
visible: bool | Literal["hidden"]
= True
Whether the component is visible or hidden.
elem_id: str | None
elem_id: str | None
= None
HTML ID for the component.
elem_classes: list[str] | str | None
elem_classes: list[str] | str | None
= None
HTML classes for the component.
render: bool
render: bool
= True
Whether to render the component in the Blocks context.
key: int | str | tuple[int | str, ...] | None
key: int | str | tuple[int | str, ...] | None
= None
Identifier for preserving component state across re-renders.
preserved_by_key: list[str] | str | None
preserved_by_key: list[str] | str | None
= "value"
Parameters to preserve during re-renders.
columns: int | None
columns: int | None
= 2
Number of columns in the grid.
rows: int | None
rows: int | None
= None
Number of rows in the grid.
height: int | float | str | None
height: int | float | str | None
= None
Height of the gallery in pixels or CSS units.
allow_preview: bool
allow_preview: bool
= True
Whether images can be enlarged on click.
preview: bool | None
preview: bool | None
= None
Whether to start in preview mode (requires allow_preview=True).
selected_index: int | None
selected_index: int | None
= None
Index of the initially selected media item.
object_fit: Literal[
"contain", "cover", "fill", "none", "scale-down"
]
| None
object_fit: Literal[
"contain", "cover", "fill", "none", "scale-down"
]
| None
= None
CSS object-fit for thumbnails ("contain", "cover", etc.).
show_share_button: bool | None
show_share_button: bool | None
= None
Whether to show a share button (auto-enabled on Hugging Face Spaces).
show_download_button: bool | None
show_download_button: bool | None
= True
Whether to show a download button for the selected media.
interactive: bool | None
interactive: bool | None
= None
Whether the gallery allows uploads.
type: Literal["numpy", "pil", "filepath"]
type: Literal["numpy", "pil", "filepath"]
= "filepath"
Format for images passed to the prediction function ("numpy", "pil", "filepath").
show_fullscreen_button: bool
show_fullscreen_button: bool
= True
Whether to show a fullscreen button.
only_custom_metadata: bool
only_custom_metadata: bool
= True
Whether to filter out technical EXIF metadata in the popup.
popup_metadata_width: int | str
popup_metadata_width: int | str
= 500
Width of the metadata popup (pixels or CSS string).
select
select
Event listener for when the user selects or deselects the MediaGallery. Uses event data gradio.SelectData to carry `value` referring to the label of the MediaGallery, and `selected` to refer to state of the MediaGallery. See EventData documentation on how to use this event data
change
change
Triggered when the value of the MediaGallery changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.
delete
delete
This listener is triggered when the user deletes and item from the MediaGallery. Uses event data gradio.DeletedFileData to carry `value` referring to the file that was deleted as an instance of FileData. See EventData documentation on how to use this event data
preview_close
preview_close
Triggered when the MediaGallery preview is closed by the user.
preview_open
preview_open
Triggered when the MediaGallery preview is opened by the user.
load_metadata
load_metadata
Triggered when the user clicks the 'Load Metadata' button in the metadata popup. Returns a dictionary of image metadata.