Skip to main content

Image Gallery Widget

The IQNOX Image Gallery is a widget that can be used to either display an image or an image gallery. For example, when navigating to an asset page, you could display an image, and when clicking on that image, the user could see the image expanded in a preview modal, or see all the existing photos of that asset, including manuals, etc.

Image preview supports zoom, mirror, flip and rotate actions, and it also allows the user to navigate through images using the arrow keys, and the modal buttons or the Esc key to close the modal. When the image is zoomed, the user can also drag the image, to change its position.

Whether the widget is a normal image with a preview or an image gallery depends on the Data property. If there are any images in the Data infotable, when clicking on the widget, the preview modal will display the images from the infotable. If the infotable does not exist or is empty, the preview modal will display the image in the SourceURL.

info

The Data infotable can now contain all types of files. A ContentTypeField can exist in the Datashape that is used to inform the widget of the type of file in each row.

In the modal, the following files types have previews:

  • Videos, using a video element (everything with a ContentType of video/*)
  • Audio, using an audio element ( audio/* )
  • PDFs, using an embed (content type of application/pdf )
  • Anything else will get displayed as a text that shows the file name, description, and a download link.
info

If the file fails to load, the fallback image will be shown.

When data is bound to the widget, the first image that has a valid source url will be found, with a content type that is either an image or is empty. If no image is found, then the fallback image will be used.

If the ContentTypeField is not set, the widget will try to infer the file type from the URL. If not, it will default to showing an image. This is done to maintain compatibility with the existing widget added two new services, ShowGalleryModal and HideGalleryModal.

For example: We have the following URL, http://example.com/myfile.zip, the URL will get inferred as having the ContentType of application/zip, if the URL does not end with an extension, the widget will assume the content type is image/*.

Usage

Properties

PropertyTypeBindingDefaultDescription
CustomClassSTRING<>Enables you to define an html class to the top div of the widget and on the modal. Multiple classes can be entered, separated by space.
TemplateLIST<Template1The widget template to use for this widget.
AlternateTextSTRING(localized)<Used as a title for preview when widget is used for a single image preview. This property will be overridden by the Name field from the Data infotable.
SourceURLIMAGELINK<Media entity select, URL to an image or base64. If there are any rows in the Data infotable, they will override the SourceURL in the image preview.
FallbackImageIMAGELINK<Image to show if the source is broken or missing.
ScalingLISTContainHow the image will scale within its container.
ContentTypeFieldFIELDNAMEThe name of the data field corresponding to the file alternate text.
DataINFOTABLE<List of files to show as slideshow
SourceUrlFieldLISTThe name of the data field corresponding to the file source url.
NameFieldLISTThe name of the data field corresponding to the file name.
AlternateTextFieldLISTThe name of the data field corresponding to the file alternate text.
AllowPreviewBOOLEANTRUEAllows the user to preview the entire Data or the current SourceUrl.
PreviewButtonTextSTRING(localized)<PreviewPreview button text.
PreviewIconUriSTRING<material-outlined:visibilityURI describing the icon that's going to be used in the preview button. Either a HTTP link or a reference to an icon in an icon font can be used.
ShowImageControlsBOOLEANTRUEList of control buttons to help the user mirror/rotate/zoom on the previewed image.
ShowCountInPreviewBOOLEANTRUEShows the current file number and number of files in the modal preview. This only applies for the files from the Data infotable.
ShowTilesInPreviewBOOLEANTRUEShows small thumbnails of files in preview from the Data infotable.
ShowTitleBOOLEANTRUEIf the images come from Data, it will show the NameField field in the image preview, using the AlternateTextField field as fallback. If Data is empty it will show the AlternateText widget property.
ShowCountLISTDon't showShow counter on image.
ShowDownloadBOOLEANFALSEAllows the user to download the file from the preview.
ShowDeleteBOOLEANFALSEShows a delete button in the the control buttons list that will display a confirmation dialogue and trigger the OnDeleteTriggered event when confirmed.
ConfirmationTitleSTRING(localized)<Delete FileTitle displayed in the confirmation popup shown when deleting a file.
ConfirmationPromptSTRING(localized)<Are you sure you want to delete this file?Message displayed in the confirmation popup when deleting a file.
DefaultConfirmationButtonLISTFirst buttonSets the position of the confirmation button in the popup: first or second.
ConfirmationButton1LabelSTRING(localized)<DeleteText displayed on the first button in the confirmation dialog.
ConfirmationButton1ClassSTRINGCustom CSS class used to style the first button in the confirmation popup.
ConfirmationButton2LabelSTRING(localized)<CancelText displayed on the second button in the confirmation dialog.
ConfirmationButton2ClassSTRINGCustom CSS class used to style the second button in the confirmation popup.
ConfirmMessageIconURISTRING<URI of the icon displayed in the delete confirmation message.
ConfirmationIsModalBOOLEANFALSEDetermines whether the delete confirmation is a popup or a modal.
ClickOutsideToCloseBOOLEANTRUEClose the modal by clicking outside of the file, on the modal overlay.
IsOpenBOOLEAN>Whether the gallery modal is currently open.
IsLoadingBOOLEAN<>Indicates whether the modal gallery is currently in a loading state. Automatically updated when either AutomaticServiceLoadingIndicator or ShowImgSrcLoading is enabled, but can also be set manually to force the loading state.˝
AutomaticServiceLoadingIndicatorBOOLEANAutomatically update the gallery loading state based on the status of the service bound to the Data property.
ShowImgSrcLoadingBOOLEANWhether to display the loading indicator while the browser resolves the main image's source in the gallery modal. When enabled, the overall IsLoading state will also be set while the image is loading.
SelectedRowINFOTABLE>The currently selected file in the gallery. Empty when the modal is closed.
RememberLastSelectionBOOEALNWhether the gallery should remember the last selected file when the modal is reopened.
TooltipSTRING(localized)<Optional tooltip used to display additional information. See Tooltip.
TooltipAnchorSTRINGWidgetIf the tooltip should appear next to the Widget, or next to the cursor.
TooltipTypeLIST<TextThe widget tooltip type.
TooltipWidthNUMBERTooltip width.

Events

PropertyTypeBindingDescription
OnLoadEVENT>Triggers after the image was loaded
OnDeleteTriggeredEVENT>Triggered when the delete button is pressed
OnSelectionChangedEVENT>Triggered when file displayed in the modal changes.
OnModalOpenedEVENT>Triggered when the gallery modal is opened.
OnModalClosedEVENT>Triggered when the gallery modal is closed.

Services

PropertyTypeBindingDescription
HideGalleryModalSERVICE<Hides the gallery modal to view the files
ShowGalleryModalSERVICE<Shows the gallery modal to view the files

Examples

Delete functionality

This example demonstrates how to implement the delete functionality in a widget.

Configuration

To enable the delete functionality, ensure that:

  1. The AllowPreview property is set to true.
  2. The ShowDelete property is set to true.

Behavior

  1. When the delete button is pressed, the OnDeleteTriggered event is invoked.
  2. The file selected at the time of deletion will be available:
  • In the Selected Row(s) property of the service bound to the Data property, or
  • In the SelectedRow property on the widget itself.
  1. The IsLoading property can be set to true via binding, to provide feedback preemptively that the Data infotable will change (optional).
  2. If the AutomaticServiceLoadingIndicator property is true, the IsLoading property will automatically reset to false once the Data property refreshes. Otherwise, you must manually reset IsLoading to false.