-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Rias: Images not loading in Safari Reader View and Instapaper #110
Comments
Honestly, I don't really understand this reader view. In my test even if images are loaded in normal view, they are wrong in reader view. To me it seems, that reader view a) somehow uses a server cache to store the output and b) uses some heuristics to generate this "wrong" If I'm correct, you could give the reader what he needs, by changing your
And then using the following JS to give lazySizes what he needs:
Not sure, but it might be possible, that you need to update your content so that the cache isn't kicking in. |
@aFarkas great this solves my issue; setting a default width and quality for readers like Instapaper! |
Hmm, and how would I do the same for Rias + Bgset? Also see my related (and now) closed issue #101, and an example. Just targeting |
Are you sure? The following script should work just fine for document.addEventListener('lazybeforeunveil', function(e){
var srcAttr = 'data-src';
var src = e.target.getAttribute(srcAttr);
if(!src){
srcAttr = 'data-bgset';
src = e.target.getAttribute(srcAttr);
if(!src){return;}
}
e.target.setAttribute(srcAttr, src.replace(/s=w(\d+)/, 's=w{width}').replace(/o=(\d+)/, 'o={quality}'));
}); |
Yeah it is working on stage (http://altair.studiodumbar.com) in latest stable Chrome, Safari and FF. But I was testing locally, and the <div data-bgset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg" class="BgImage lazyload"></div> And this is the output in Safari (and FF): <div data-bgset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg" class="BgImage lazyloaded">
<picture style="display: none;">
<source data-srcset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg" sizes="1278px" srcset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg">
<img class=" lazyautosizes lazyloaded" data-sizes="auto" sizes="1278px">
</picture>
</div> The class is changed to And this is the output in Chrome: <div data-bgset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg" class="BgImage lazyloaded" style="background-image: url(http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg);">
<picture style="display: none;">
<source data-srcset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg" sizes="810px" srcset="http://local.altair/thumbs/cover-01-0592393299182fce9d720a97aa745dd5.jpg"
<img class=" lazyautosizes lazyloaded" data-sizes="auto" sizes="810px">
</picture>
</div> And (strangely?) enough it is working in Chrome locally. And as far as I recall it was working locally in Safari before… Do you have any idea? Writing and debugging javascript is not what I do daily… thanks again for your help! BTW I'm using the latest versions of lazysizes and plugins (v1.1.3-RC1). |
Can you change your local
or
Or try by also adding the respimg polyfill https://github.com/aFarkas/lazysizes/tree/gh-pages/plugins/respimg. Reason: the rias extension only includes a partial picture/srcset polyfill and needs to find a src with the corresponding pattern. |
Adding the I also tried adding the respimg polypill, and though it made the background image loading work locally even without adding the Not directly related to this issue, but I wanted to ask you anyway: have you seen this post by Mat Marquis at CSS-tricks, about updating picturefill? I have no idea if it touches your code or not, and probably you already read about it… anyway, thanks again for the script (it works so much more ‘smoothly’ then other lazyload scrips I have tried!) and your help. |
Safari Reader View
Images that have not yet been loaded before Safari's (v8.0.6) Reader View is invoked, will not load in Reader View (see screenshot below) at all.
(link to page)
Instapaper (article view in browser)
Very likely related to the Safari Reader View issue, is the issue of images not being loaded in an article being saved to Instapaper (or Pocket for that matter). Again the {width} and {quality} placeholders are not being replaced. The Instapaper ‘scraper’ apparently does not trigger the Rias plugin, just like Safari's Reader View doesn't… (see screenshot below).
(link to page)
Any ideas? Possible to solve? Thanks (again) for your help and really great script.
The text was updated successfully, but these errors were encountered: