Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The image loading attribute depends only on the fetchpriority value #393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
* 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 Expand Up @@ -324,7 +320,7 @@
product: ProductSummaryTypes.Product
position: number | undefined
} = useProductSummary()
const { handles, withModifiers } = useCssHandles(CSS_HANDLES, { classes })

Check warning on line 323 in react/ProductSummaryImage.tsx

View workflow job for this annotation

GitHub Actions / Lint

Expected blank line before this statement

const [error, setError] = useState(false)
const onError = () => setError(true)
Expand Down
Loading