@@ -391,7 +391,7 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
391391 // By doing this, the image "pops" into the timeline, but is still restricted
392392 // by the same width and height logic below.
393393 if ( ! this . state . loadedImageDimensions ) {
394- let imageElement ;
394+ let imageElement : JSX . Element ;
395395 if ( ! this . state . showImage ) {
396396 imageElement = < HiddenImagePlaceholder /> ;
397397 } else {
@@ -425,7 +425,13 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
425425 let gifLabel : JSX . Element ;
426426
427427 if ( ! this . props . forExport && ! this . state . imgLoaded ) {
428- placeholder = this . getPlaceholder ( maxWidth , maxHeight ) ;
428+ const classes = classNames ( 'mx_MImageBody_placeholder' , {
429+ 'mx_MImageBody_placeholder--blurhash' : this . props . mxEvent . getContent ( ) . info ?. [ BLURHASH_FIELD ] ,
430+ } ) ;
431+
432+ placeholder = < div className = { classes } >
433+ { this . getPlaceholder ( maxWidth , maxHeight ) }
434+ </ div > ;
429435 }
430436
431437 let showPlaceholder = Boolean ( placeholder ) ;
@@ -463,29 +469,26 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
463469 banner = this . getBanner ( content ) ;
464470 }
465471
466- const classes = classNames ( {
467- 'mx_MImageBody_placeholder' : true ,
468- 'mx_MImageBody_placeholder--blurhash' : this . props . mxEvent . getContent ( ) . info ?. [ BLURHASH_FIELD ] ,
469- } ) ;
470-
471472 // many SVGs don't have an intrinsic size if used in <img> elements.
472473 // due to this we have to set our desired width directly.
473474 // this way if the image is forced to shrink, the height adapts appropriately.
474475 const sizing = infoSvg ? { maxHeight, maxWidth, width : maxWidth } : { maxHeight, maxWidth } ;
475476
477+ if ( ! this . props . forExport ) {
478+ placeholder = < SwitchTransition mode = "out-in" >
479+ < CSSTransition
480+ classNames = "mx_rtg--fade"
481+ key = { `img-${ showPlaceholder } ` }
482+ timeout = { 300 }
483+ >
484+ { showPlaceholder ? placeholder : < > </ > /* Transition always expects a child */ }
485+ </ CSSTransition >
486+ </ SwitchTransition > ;
487+ }
488+
476489 const thumbnail = (
477490 < div className = "mx_MImageBody_thumbnail_container" style = { { maxHeight, maxWidth, aspectRatio : `${ infoWidth } /${ infoHeight } ` } } >
478- < SwitchTransition mode = "out-in" >
479- < CSSTransition
480- classNames = "mx_rtg--fade"
481- key = { `img-${ showPlaceholder } ` }
482- timeout = { 300 }
483- >
484- { showPlaceholder ? < div className = { classes } >
485- { placeholder }
486- </ div > : < > </ > /* Transition always expects a child */ }
487- </ CSSTransition >
488- </ SwitchTransition >
491+ { placeholder }
489492
490493 < div style = { sizing } >
491494 { img }
@@ -494,7 +497,9 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
494497 </ div >
495498
496499 { /* HACK: This div fills out space while the image loads, to prevent scroll jumps */ }
497- { ! this . state . imgLoaded && < div style = { { height : maxHeight , width : maxWidth } } /> }
500+ { ! this . props . forExport && ! this . state . imgLoaded && (
501+ < div style = { { height : maxHeight , width : maxWidth } } />
502+ ) }
498503
499504 { this . state . hover && this . getTooltip ( ) }
500505 </ div >
@@ -559,9 +564,12 @@ export default class MImageBody extends React.Component<IBodyProps, IState> {
559564 ) ;
560565 }
561566
562- const contentUrl = this . state . contentUrl ;
567+ let contentUrl = this . state . contentUrl ;
563568 let thumbUrl : string ;
564- if ( this . props . forExport || ( this . state . isAnimated && SettingsStore . getValue ( "autoplayGifs" ) ) ) {
569+ if ( this . props . forExport ) {
570+ contentUrl = this . props . mxEvent . getContent ( ) . url ?? this . props . mxEvent . getContent ( ) . file ?. url ;
571+ thumbUrl = contentUrl ;
572+ } else if ( this . state . isAnimated && SettingsStore . getValue ( "autoplayGifs" ) ) {
565573 thumbUrl = contentUrl ;
566574 } else {
567575 thumbUrl = this . state . thumbUrl ?? this . state . contentUrl ;
0 commit comments