Displays an image with preview and tranformation options.
import { ImageModule } from 'primeng/image';
Image is used as the native img element and supports all properties that the native element has. For multiple image, see Galleria.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
alt="Image"
width="250" />
Preview mode displays a modal layer when the image is clicked that provides transformation options such as rotating and zooming.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
alt="Image"
width="250"
[preview]="true" />
An eye icon is displayed by default when the image is hovered in preview mode. Use the indicator template for custom content.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria10.jpg"
[preview]="true"
alt="Image"
width="250">
<ng-template pTemplate="indicator">
<i class="pi pi-check"></i>
</ng-template>
</p-image>
In case that you want to show different image on preview, you can set previewImageSrc attribute. It could come handy when wanted to use smaller image version at first and bigger one on preview.
<p-image
src="https://primefaces.org/cdn/primeng/images/galleria/galleria11.jpg"
previewImageSrc="https://primefaces.org/cdn/primeng/images/galleria/galleria11.jpg"
alt="Image"
width="250"
[preview]="true" />
The preview button is a native button element with an aria-label that refers to the aria.zoomImage property of the locale API by default.
When preview is active, dialog role with aria-modal is applied to the overlay image container.
Button controls use aria.rotateRight, aria.rotateLeft, aria.zoomIn, aria.zoomOut and aria.close from the locale API as aria-label.
When preview is activated, close button receives the initial focus.
Key | Function |
---|---|
tab | Moves focus through button bar. |
enter | Activates the button. |
space | Activates the button. |
esc | Closes the image preview. |