Merge pull request #1744 from omnivore-app/fix/wechat-image

Fix not showing images in wechat articles
This commit is contained in:
Hongbo Wu 2023-01-31 09:21:39 +08:00 committed by GitHub
commit c3e6321b3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -526,7 +526,8 @@ Readability.prototype = {
// replace all images' href source
const images = articleContent.getElementsByTagName('img');
Array.from(images).forEach(image => {
const src = image.getAttribute("src");
// use data-src if lazy loading
const src = image.getAttribute("data-src") || image.getAttribute("src");
// do not proxy data uri
if (src && !dataUriRegex.test(src)) {
@ -545,6 +546,9 @@ Readability.prototype = {
const proxySrc = this.createImageProxyUrl(absoluteSrc, width, height);
image.setAttribute('src', proxySrc);
}
// remove crossorigin attribute to avoid CORS errors
image.removeAttribute('crossorigin');
});
// replace all srcset's