From 0e80e6f3539868d4cc32bd8def939106b7c06725 Mon Sep 17 00:00:00 2001 From: Mossroy Date: Fri, 5 Jan 2018 12:40:00 +0100 Subject: [PATCH] Fix a regression on some images in ServiceWorker mode. Fixes #329 It was affecting all tags of the first displayed article, only in ServiceWorker mode. --- www/js/app.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 3132ac1f..bcbdf7de 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -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(/(]*\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(/(]*\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