Fix image display for Gutenberg in SW mode

Former-commit-id: 030fb997bcef4be558cd001ce3b78f5d1dc0986a [formerly a974dfb5b80347da589130afd45b1412286b73fd] [formerly 3bf2d7bfee30a093285b56292d18859546f9c850] [formerly 747b8193312c14aaaf722d1f2bcea4990d69b23a [formerly 5b75942a1827883754193d28ba152748fe07274f [formerly 155207bf97755bdffa42c4912df74a90cf536602]]]
Former-commit-id: f98a73277a88c0e35a0a65da0d7aa0df1647d9a6 [formerly 86ab6924f0de15cf2f1f87c8cfbbd216704c818e [formerly 8d419fa56648439a8b12762f949b18d036457112]]
Former-commit-id: 509bc3f582cd2ba084dc555d8bec9fde5d27be85 [formerly c19cb7703d53977009d47ff96ed376de21b60146]
Former-commit-id: df6ef6a2b2823d4c774417c38d0f491858a48aaa
This commit is contained in:
Jaifroid 2021-06-12 11:30:27 +01:00
parent f59cb04781
commit 0f58ab8d4e

View File

@ -3190,6 +3190,10 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
// UWP apps with windows need to allow all images in all throughput
if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
params.imageDisplay) { imageDisplayMode = 'all'; }
// We need to do the same for Gutenberg and PHET ZIMs
if (/gutenberg|phet/i.test(appstate.selectedArchive._file._files[0].name)) {
imageDisplayMode = 'all';
}
if (/\bhtml\b/i.test(mimetype)) {
// Intercept files of type html and apply transformations
var message = {
@ -3204,10 +3208,14 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
var postTransformedHTML = function() {
clearTimeout(timer);
if (params.transformedHTML && /<html[^>]*>/.test(params.transformedHTML)) {
// Because UWP app window can only be controlled from the Service Worker, we have to allow all images
// to be called from any external windows
if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
params.imageDisplay) { imageDisplayMode = 'all'; }
// // Because UWP app window can only be controlled from the Service Worker, we have to allow all images
// // to be called from any external windows
// if (/UWP/.test(params.appType) && (appstate.target === 'window' || appstate.messageChannelWaiting) &&
// params.imageDisplay) { imageDisplayMode = 'all'; }
// // We need to do the same for Gutenberg and PHET ZIMs
// if (/gutenberg|phet/i.test(appstate.selectedArchive._file._files[0].name)) {
// imageDisplayMode = 'all';
// }
appstate.messageChannelWaiting = false;
// Let's send the content to the ServiceWorker
thisMessage.content = params.transformedHTML;
@ -4351,7 +4359,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'util', 'cache', 'images', 'sett
if (params.preloadingAllImages !== true) {
$('#searchingArticles').show();
params.preloadingAllImages = true;
if (params.imageDisplay) params.contentInjectionMode == 'jquery' ?
if (params.imageDisplay) params.contentInjectionMode === 'jquery' ?
images.prepareImagesJQuery(articleWindow, true) : images.prepareImagesServiceWorker(articleWindow, true);
return;
}