Added loading=lazy to images

• Added:
- loading=lazy to images
This commit is contained in:
mgabdev 2020-08-17 16:28:04 -05:00
parent 7dadb125a2
commit bd20fd5ac5
3 changed files with 6 additions and 4 deletions

View File

@ -8,7 +8,7 @@ export default class Image extends React.PureComponent {
static propTypes = { static propTypes = {
alt: PropTypes.string.isRequired, alt: PropTypes.string.isRequired,
src: PropTypes.string, isLazy: PropTypes.string,
className: PropTypes.string, className: PropTypes.string,
width: PropTypes.oneOfType([ width: PropTypes.oneOfType([
PropTypes.string, PropTypes.string,
@ -44,7 +44,7 @@ export default class Image extends React.PureComponent {
fit, fit,
className, className,
nullable, nullable,
lazy, isLazy,
imageRef, imageRef,
...otherProps ...otherProps
} = this.props } = this.props
@ -75,6 +75,7 @@ export default class Image extends React.PureComponent {
ref={imageRef} ref={imageRef}
src={src} src={src}
onError={this.handleOnError} onError={this.handleOnError}
loading={isLazy ? 'lazy' : undefined}
/> />
) )
} }

View File

@ -185,6 +185,7 @@ class Item extends ImmutablePureComponent {
style={{ borderRadius }} style={{ borderRadius }}
> >
<img <img
loading='lazy'
src={previewUrl} src={previewUrl}
srcSet={srcSet} srcSet={srcSet}
sizes={sizes} sizes={sizes}

View File

@ -178,7 +178,7 @@ export default class StatusCard extends ImmutablePureComponent {
// : todo : use <Image /> // : todo : use <Image />
let embed = '' let embed = ''
const thumbnail = interactive ? const thumbnail = interactive ?
<img alt={''} src={cardImg} className={[_s.default, _s.objectFitCover, _s.posAbs, _s.width100PC, _s.height100PC, _s.top0, _s.right0, _s.bottom0, _s.left0].join(' ')} /> <img loading='lazy' alt={''} src={cardImg} className={[_s.default, _s.objectFitCover, _s.posAbs, _s.width100PC, _s.height100PC, _s.top0, _s.right0, _s.bottom0, _s.left0].join(' ')} />
: :
( (
<ResponsiveClassesComponent <ResponsiveClassesComponent
@ -186,7 +186,7 @@ export default class StatusCard extends ImmutablePureComponent {
classNamesSmall={[_s.default, _s.height260PX, _s.width100PC].join(' ')} classNamesSmall={[_s.default, _s.height260PX, _s.width100PC].join(' ')}
classNamesXS={[_s.default, _s.height200PX, _s.width100PC].join(' ')} classNamesXS={[_s.default, _s.height200PX, _s.width100PC].join(' ')}
> >
<img alt={''} src={cardImg} className={[_s.default, _s.objectFitCover, _s.width100PC, _s.height100PC].join(' ')} /> <img loading='lazy' alt={''} src={cardImg} className={[_s.default, _s.objectFitCover, _s.width100PC, _s.height100PC].join(' ')} />
</ResponsiveClassesComponent> </ResponsiveClassesComponent>
) )