@@ -72,7 +72,8 @@ export interface InternalPreviewConfig {
7272 /** Better to use `classNames.root` instead */
7373 rootClassName ?: string ;
7474
75- // Image
75+ // Media
76+ type ?: 'image' | 'video' ;
7677 src ?: string ;
7778 alt ?: string ;
7879
@@ -121,8 +122,9 @@ export interface PreviewProps extends InternalPreviewConfig {
121122 } ;
122123 fallback ?: string ;
123124
124- // Preview image
125+ // Preview media
125126 imgCommonProps ?: React . ImgHTMLAttributes < HTMLImageElement > ;
127+ videoCommonProps ?: React . VideoHTMLAttributes < HTMLVideoElement > ;
126128 width ?: string | number ;
127129 height ?: string | number ;
128130
@@ -165,6 +167,7 @@ const Preview: React.FC<PreviewProps> = props => {
165167 const {
166168 prefixCls,
167169 rootClassName,
170+ type = 'image' ,
168171 src,
169172 alt,
170173 imageInfo,
@@ -425,13 +428,15 @@ const Preview: React.FC<PreviewProps> = props => {
425428 { /* Body */ }
426429 < div className = { classnames ( `${ prefixCls } -body` , classNames . body ) } style = { bodyStyle } >
427430 { /* Preview Image */ }
428- { imageRender
429- ? imageRender ( imgNode , {
430- transform,
431- image,
432- ...( groupContext ? { current } : { } ) ,
433- } )
434- : imgNode }
431+ { type === 'image' &&
432+ ( imageRender
433+ ? imageRender ( imgNode , {
434+ transform,
435+ image,
436+ ...( groupContext ? { current } : { } ) ,
437+ } )
438+ : imgNode ) }
439+ { type === 'video' && < video src = { src } width = { props . width } height = { props . height } controls autoPlay /> }
435440 </ div >
436441
437442 { /* Close Button */ }
@@ -454,37 +459,38 @@ const Preview: React.FC<PreviewProps> = props => {
454459 />
455460 ) }
456461
457- { /* Footer */ }
458- < Footer
459- prefixCls = { prefixCls }
460- showProgress = { showOperationsProgress }
461- current = { current }
462- count = { count }
463- showSwitch = { showLeftOrRightSwitches }
464- // Style
465- classNames = { classNames }
466- styles = { styles }
467- // Render
468- image = { image }
469- transform = { transform }
470- icons = { icons }
471- countRender = { countRender }
472- actionsRender = { actionsRender }
473- // Scale
474- scale = { scale }
475- minScale = { minScale }
476- maxScale = { maxScale }
477- // Actions
478- onActive = { onActive }
479- onFlipY = { onFlipY }
480- onFlipX = { onFlipX }
481- onRotateLeft = { onRotateLeft }
482- onRotateRight = { onRotateRight }
483- onZoomOut = { onZoomOut }
484- onZoomIn = { onZoomIn }
485- onClose = { onClose }
486- onReset = { onReset }
487- />
462+ { type === 'image' && (
463+ < Footer
464+ prefixCls = { prefixCls }
465+ showProgress = { showOperationsProgress }
466+ current = { current }
467+ count = { count }
468+ showSwitch = { showLeftOrRightSwitches }
469+ // Style
470+ classNames = { classNames }
471+ styles = { styles }
472+ // Render
473+ image = { image }
474+ transform = { transform }
475+ icons = { icons }
476+ countRender = { countRender }
477+ actionsRender = { actionsRender }
478+ // Scale
479+ scale = { scale }
480+ minScale = { minScale }
481+ maxScale = { maxScale }
482+ // Actions
483+ onActive = { onActive }
484+ onFlipY = { onFlipY }
485+ onFlipX = { onFlipX }
486+ onRotateLeft = { onRotateLeft }
487+ onRotateRight = { onRotateRight }
488+ onZoomOut = { onZoomOut }
489+ onZoomIn = { onZoomIn }
490+ onClose = { onClose }
491+ onReset = { onReset }
492+ />
493+ ) }
488494 </ div >
489495 ) ;
490496 } }
0 commit comments