Skip to content

Commit

Permalink
The image loading attribute depends only on the fetchpriority value
Browse files Browse the repository at this point in the history
  • Loading branch information
cavaglieridomenico authored Sep 25, 2024
1 parent a696de2 commit 92cccb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- The logic of the `loading` attribute depends only on the `fetchpriority` value and no longer on the image resizing

## [2.90.0] - 2024-08-01

### Added
Expand Down
8 changes: 2 additions & 6 deletions react/ProductSummaryImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,15 @@ function Image({
* device-based guess was wrong. Has to be looked into */
const dpi = isMobile ? 2 : 1

const shouldResize = !!(width || height)

return (
<img
src={getImageSrc({ src, width, height, dpi, aspectRatio })}
style={getStyle({ width, height, aspectRatio, maxHeight })}
// @ts-expect-error This property exists in HTML
loading={
shouldResize ? 'lazy' : fetchpriority === 'high' ? 'eager' : 'auto'
}
loading={fetchpriority === 'low' ? 'lazy' : 'eager'}
alt={alt}
className={className}
onError={onError}
// @ts-expect-error This property exists in HTML
fetchpriority={fetchpriority}
/>
)
Expand Down

0 comments on commit 92cccb0

Please sign in to comment.