@@ -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,24 @@ 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' && (
440+ < video
441+ className = { `${ prefixCls } -video` }
442+ src = { src }
443+ width = { props . width }
444+ height = { props . height }
445+ controls
446+ autoPlay
447+ />
448+ ) }
435449 </ div >
436450
437451 { /* Close Button */ }
@@ -454,37 +468,38 @@ const Preview: React.FC<PreviewProps> = props => {
454468 />
455469 ) }
456470
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- />
471+ { type === 'image' && (
472+ < Footer
473+ prefixCls = { prefixCls }
474+ showProgress = { showOperationsProgress }
475+ current = { current }
476+ count = { count }
477+ showSwitch = { showLeftOrRightSwitches }
478+ // Style
479+ classNames = { classNames }
480+ styles = { styles }
481+ // Render
482+ image = { image }
483+ transform = { transform }
484+ icons = { icons }
485+ countRender = { countRender }
486+ actionsRender = { actionsRender }
487+ // Scale
488+ scale = { scale }
489+ minScale = { minScale }
490+ maxScale = { maxScale }
491+ // Actions
492+ onActive = { onActive }
493+ onFlipY = { onFlipY }
494+ onFlipX = { onFlipX }
495+ onRotateLeft = { onRotateLeft }
496+ onRotateRight = { onRotateRight }
497+ onZoomOut = { onZoomOut }
498+ onZoomIn = { onZoomIn }
499+ onClose = { onClose }
500+ onReset = { onReset }
501+ />
502+ ) }
488503 </ div >
489504 ) ;
490505 } }
0 commit comments