Merge pull request #330 from kiwix/fix-some-images-in-serviceworker-mode

Fix a regression on some images in ServiceWorker mode.
This commit is contained in:
Mossroy 2018-01-05 13:43:38 +01:00 committed by GitHub
commit 53a111a000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -806,9 +806,11 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
// Scroll the iframe to its top
$("#articleContent").contents().scrollTop(0);
if (contentInjectionMode === 'jquery') {
// Fast-replace img src with data-kiwixsrc [kiwix-js #272]
htmlArticle = htmlArticle.replace(/(<img\s+[^>]*\b)src(\s*=)/ig, "$1data-kiwixsrc$2");
}
// Display the article inside the web page.
//Fast-replace img with data-img and hide image [kiwix-js #272]
htmlArticle = htmlArticle.replace(/(<img\s+[^>]*\b)src(\s*=)/ig, "$1data-kiwixsrc$2");
$('#articleContent').contents().find('body').html(htmlArticle);
// If the ServiceWorker is not useable, we need to fallback to parse the DOM