Skip to content

Commit f6ee04b

Browse files
author
Nir Maoz
authored
Fix lazy loading of responsive images in Safari (#184)
1 parent a7d202a commit f6ee04b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/components/Image/Image.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class Image extends CloudinaryComponent {
4242
const extendedProps = this.getExtendedProps();
4343
const {children, innerRef, ...options} = {...extendedProps, ...this.getTransformation(extendedProps)};
4444

45+
if (!this.shouldLazyLoad()){
46+
delete options.loading;
47+
}
48+
4549
return options;
4650
}
4751

test/ImageTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ describe('Image', () => {
198198

199199
expect(tag.state().isInView).to.equal(true);
200200
expect(tag.html()).to.equal([
201-
`<img loading="lazy" src="http://res.cloudinary.com/demo/image/upload/sample" style="opacity:0;position:absolute"/>`,
201+
`<img src="http://res.cloudinary.com/demo/image/upload/sample" style="opacity:0;position:absolute"/>`,
202202
`<div style="display:inline">`,
203-
`<img loading="lazy" src="http://res.cloudinary.com/demo/image/upload/e_blur:2000,f_auto,q_1/sample"/>`,
203+
`<img src="http://res.cloudinary.com/demo/image/upload/e_blur:2000,f_auto,q_1/sample"/>`,
204204
`</div>`
205205
].join(''));
206206
});

0 commit comments

Comments
 (0)