Skip to content

Commit

Permalink
[core] Fix image loading bug on Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Sep 14, 2023
1 parent 427aa20 commit b59570b
Show file tree
Hide file tree
Showing 36 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export default function UnstyledSelectRichOptions() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${c.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
alt={`Flag of ${c.label}`}
/>
{c.label} ({c.code}) +{c.phone}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default function UnstyledSelectRichOptions() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${c.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
alt={`Flag of ${c.label}`}
/>
{c.label} ({c.code}) +{c.phone}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${c.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${c.code.toLowerCase()}.png`}
alt={`Flag of ${c.label}`}
/>
{c.label} ({c.code}) +{c.phone}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/CarouselRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function CarouselRatio() {
<Card orientation="horizontal" size="sm" key={item.title} variant="outlined">
<AspectRatio ratio="1" sx={{ minWidth: 60 }}>
<img
src={`${item.src}?h=120&fit=crop&auto=format`}
srcSet={`${item.src}?h=120&fit=crop&auto=format&dpr=2 2x`}
src={`${item.src}?h=120&fit=crop&auto=format`}
alt={item.title}
/>
</AspectRatio>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/CarouselRatio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export default function CarouselRatio() {
<Card orientation="horizontal" size="sm" key={item.title} variant="outlined">
<AspectRatio ratio="1" sx={{ minWidth: 60 }}>
<img
src={`${item.src}?h=120&fit=crop&auto=format`}
srcSet={`${item.src}?h=120&fit=crop&auto=format&dpr=2 2x`}
src={`${item.src}?h=120&fit=crop&auto=format`}
alt={item.title}
/>
</AspectRatio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<Card orientation="horizontal" size="sm" key={item.title} variant="outlined">
<AspectRatio ratio="1" sx={{ minWidth: 60 }}>
<img
src={`${item.src}?h=120&fit=crop&auto=format`}
srcSet={`${item.src}?h=120&fit=crop&auto=format&dpr=2 2x`}
src={`${item.src}?h=120&fit=crop&auto=format`}
alt={item.title}
/>
</AspectRatio>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/ListStackRatio.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default function ListStackRatio() {
<ListItemButton sx={{ gap: 2 }}>
<AspectRatio sx={{ flexBasis: 120 }}>
<img
src={`${item.src}?w=120&fit=crop&auto=format`}
srcSet={`${item.src}?w=120&fit=crop&auto=format&dpr=2 2x`}
src={`${item.src}?w=120&fit=crop&auto=format`}
alt={item.title}
/>
</AspectRatio>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/aspect-ratio/ListStackRatio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default function ListStackRatio() {
<ListItemButton sx={{ gap: 2 }}>
<AspectRatio sx={{ flexBasis: 120 }}>
<img
src={`${item.src}?w=120&fit=crop&auto=format`}
srcSet={`${item.src}?w=120&fit=crop&auto=format&dpr=2 2x`}
src={`${item.src}?w=120&fit=crop&auto=format`}
alt={item.title}
/>
</AspectRatio>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/autocomplete/CountrySelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default function CountrySelect() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
</ListItemDecorator>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/joy/components/autocomplete/CountrySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default function CountrySelect() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
</ListItemDecorator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function EmailList() {
<ListItemDecorator sx={{ alignSelf: 'flex-start' }}>
<Avatar
alt=""
src={item.avatar}
srcSet={item.avatar2x}
src={item.avatar}
sx={{ borderRadius: 'sm' }}
/>
</ListItemDecorator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function ContrySelector({ sx, ...props }: FormControlProps) {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
</AspectRatio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default function ContrySelector({ sx, ...props }: FormControlProps) {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
</AspectRatio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default function CountrySelect() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default function CountrySelect() {
<img
loading="lazy"
width="20"
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
srcSet={`https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`}
src={`https://flagcdn.com/w20/${option.code.toLowerCase()}.png`}
alt=""
/>
{option.label} ({option.code}) +{option.phone}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default function MasonryImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default function MasonryImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function StandardImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
srcSet={`${item.img}?w=164&h=164&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function StandardImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
srcSet={`${item.img}?w=164&h=164&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
srcSet={`${item.img}?w=164&h=164&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=164&h=164&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default function TitlebarBelowImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default function TitlebarBelowImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default function TitlebarBelowMasonryImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default function TitlebarBelowMasonryImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default function TitlebarImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export default function TitlebarImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=248&fit=crop&auto=format`}
srcSet={`${item.img}?w=248&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=248&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/image-list/WovenImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function WovenImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=161&fit=crop&auto=format`}
srcSet={`${item.img}?w=161&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=161&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function WovenImageList() {
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=161&fit=crop&auto=format`}
srcSet={`${item.img}?w=161&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=161&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{itemData.map((item) => (
<ImageListItem key={item.img}>
<img
src={`${item.img}?w=161&fit=crop&auto=format`}
srcSet={`${item.img}?w=161&fit=crop&auto=format&dpr=2 2x`}
src={`${item.img}?w=161&fit=crop&auto=format`}
alt={item.title}
loading="lazy"
/>
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/masonry/ImageMasonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function ImageMasonry() {
<div key={index}>
<Label>{index + 1}</Label>
<img
src={`${item.img}?w=162&auto=format`}
srcSet={`${item.img}?w=162&auto=format&dpr=2 2x`}
src={`${item.img}?w=162&auto=format`}
alt={item.title}
loading="lazy"
style={{
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/masonry/ImageMasonry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function ImageMasonry() {
<div key={index}>
<Label>{index + 1}</Label>
<img
src={`${item.img}?w=162&auto=format`}
srcSet={`${item.img}?w=162&auto=format&dpr=2 2x`}
src={`${item.img}?w=162&auto=format`}
alt={item.title}
loading="lazy"
style={{
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/blog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ function PostPreview(props: BlogPost) {
<Avatar
key={author}
alt=""
src={`${AUTHORS[author].avatar}?s=${28}`}
srcSet={`${AUTHORS[author].avatar}?s=${28 * 2} 2x`}
src={`${AUTHORS[author].avatar}?s=${28}`}
/>
))}
</AvatarGroup>
Expand Down Expand Up @@ -264,13 +264,13 @@ export default function Blog(props: InferGetStaticPropsType<typeof getStaticProp
<main id="main-content">
<Box
sx={(theme) => ({
background: `linear-gradient(180deg, #FFF 50%,
background: `linear-gradient(180deg, #FFF 50%,
${(theme.vars || theme).palette.primary[50]} 100%)
`,
...theme.applyDarkStyles({
background: `linear-gradient(180deg, ${
(theme.vars || theme).palette.primaryDark[800]
} 50%,
} 50%,
${alpha(theme.palette.primary[900], 0.2)} 100%)
`,
}),
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/home/UserFeedbacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ function Feedback({
</Typography>
<Box sx={{ display: 'flex' }}>
<Avatar
src={profile.avatarSrc}
srcSet={profile.avatarSrcSet}
src={profile.avatarSrc}
alt={`Picture of ${profile.name}`}
imgProps={{ loading: 'lazy' }}
sx={{
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Avatar/Avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ const Avatar = React.forwardRef(function Avatar(inProps, ref) {
children = (
<AvatarImg
alt={alt}
src={src}
srcSet={srcSet}
src={src}
sizes={sizes}
ownerState={ownerState}
className={classes.img}
Expand Down

0 comments on commit b59570b

Please sign in to comment.