@@ -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,7 +122,7 @@ export interface PreviewProps extends InternalPreviewConfig {
121122 } ;
122123 fallback ?: string ;
123124
124- // Preview image
125+ // Preview media
125126 imgCommonProps ?: React . ImgHTMLAttributes < HTMLImageElement > ;
126127 width ?: string | number ;
127128 height ?: string | number ;
@@ -165,6 +166,7 @@ const Preview: React.FC<PreviewProps> = props => {
165166 const {
166167 prefixCls,
167168 rootClassName,
169+ type = 'image' ,
168170 src,
169171 alt,
170172 imageInfo,
@@ -425,13 +427,24 @@ const Preview: React.FC<PreviewProps> = props => {
425427 { /* Body */ }
426428 < div className = { classnames ( `${ prefixCls } -body` , classNames . body ) } style = { bodyStyle } >
427429 { /* Preview Image */ }
428- { imageRender
429- ? imageRender ( imgNode , {
430- transform,
431- image,
432- ...( groupContext ? { current } : { } ) ,
433- } )
434- : imgNode }
430+ { type === 'image' &&
431+ ( imageRender
432+ ? imageRender ( imgNode , {
433+ transform,
434+ image,
435+ ...( groupContext ? { current } : { } ) ,
436+ } )
437+ : imgNode ) }
438+ { type === 'video' && (
439+ < video
440+ className = { `${ prefixCls } -video` }
441+ src = { src }
442+ width = { props . width }
443+ height = { props . height }
444+ controls
445+ autoPlay
446+ />
447+ ) }
435448 </ div >
436449
437450 { /* Close Button */ }
@@ -454,37 +467,38 @@ const Preview: React.FC<PreviewProps> = props => {
454467 />
455468 ) }
456469
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- />
470+ { type === 'image' && (
471+ < Footer
472+ prefixCls = { prefixCls }
473+ showProgress = { showOperationsProgress }
474+ current = { current }
475+ count = { count }
476+ showSwitch = { showLeftOrRightSwitches }
477+ // Style
478+ classNames = { classNames }
479+ styles = { styles }
480+ // Render
481+ image = { image }
482+ transform = { transform }
483+ icons = { icons }
484+ countRender = { countRender }
485+ actionsRender = { actionsRender }
486+ // Scale
487+ scale = { scale }
488+ minScale = { minScale }
489+ maxScale = { maxScale }
490+ // Actions
491+ onActive = { onActive }
492+ onFlipY = { onFlipY }
493+ onFlipX = { onFlipX }
494+ onRotateLeft = { onRotateLeft }
495+ onRotateRight = { onRotateRight }
496+ onZoomOut = { onZoomOut }
497+ onZoomIn = { onZoomIn }
498+ onClose = { onClose }
499+ onReset = { onReset }
500+ />
501+ ) }
488502 </ div >
489503 ) ;
490504 } }
0 commit comments