Skip to content

Commit

Permalink
Merge pull request #16 from dennispassway/feature/lazy-load-image
Browse files Browse the repository at this point in the history
add loading=lazy to thumbnails in mediagrid and medialist
  • Loading branch information
dennispassway authored Jan 28, 2021
2 parents 06b9b17 + b423b5d commit 9cbaffe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/MediaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const MediaGrid = ({

const ImageItem = ({ alt, onClick, onDoubleClick, selected, url }: MediaItemProps) => (
<StyledMediaItem selected={selected} onClick={(e) => onClick(e)} onDoubleClick={onDoubleClick}>
<img alt={alt} src={`${url}?w=150&h=150&fit=crop&auto=format&q=80`} />
<img alt={alt} src={`${url}?w=150&h=150&fit=crop&auto=format&q=80`} loading="lazy" />
</StyledMediaItem>
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/MediaList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const MediaRow = ({
<div>
<StyledThumbnailContainer>
{_type === 'sanity.imageAsset' ? (
<StyledImage alt={alt} src={`${url}?w=100&h=100&fit=crop&auto=format&q=80`} />
<StyledImage alt={alt} src={`${url}?w=100&h=100&fit=crop&auto=format&q=80`} loading="lazy" />
) : (
<StyledFile>
<Icon type="file" />
Expand Down

0 comments on commit 9cbaffe

Please sign in to comment.