Skip to content

Commit a84add9

Browse files
committed
fix(card.twig): define background-image and activate dynamic cache reset for it
fix #1021 (or hope it fix it)
1 parent bec8701 commit a84add9

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

tools/bazar/presentation/javascripts/bazar-list-dynamic.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,18 @@ document.addEventListener('DOMContentLoaded', function() {
312312
cache: false,
313313
success: function (data){
314314
let previousUrl = $(newImageParams.node).prop('src');
315-
if (data.cachefilename != previousUrl){
316-
$(`img[src="${previousUrl}"]`).each(function(){
317-
$(this).prop('src',data.cachefilename);
318-
});
319-
}
315+
let srcFileName = wiki.baseUrl.replace(/(\?)?$/,'')+data.cachefilename;
316+
$(`img[src="${previousUrl}"]`).each(function(){
317+
$(this).prop('src',srcFileName);
318+
let next = $(this).next('div.area.visual-area[style]');
319+
if (next.length > 0){
320+
let backgoundImage = $(next).css('background-image');
321+
if (backgoundImage != undefined && typeof backgoundImage == "string" && backgoundImage.length > 0){
322+
$(next).css('background-image',''); // reset to force update
323+
$(next).css('background-image',`url("${srcFileName}")`);
324+
}
325+
}
326+
});
320327
},
321328
complete: function (e){
322329
if (e.responseJSON != undefined && e.responseJSON.newToken != undefined ){

tools/bazar/templates/entries/index-dynamic-templates/card.twig

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@
4040

4141
{# VISUAL AREA #}
4242
<template v-if="Object.keys(entry).includes('visual')">
43-
<img v-if="entry.visual" class="area visual-area" :src="urlImage(entry,'visual',{{ imWidth }},{{ imHeight }},'crop')"
44-
@error="urlImageResizedOnError(entry,'visual',{{ imWidth }},{{ imHeight }},'crop',{{ firstTokenCrop|json_encode }})"></img>
43+
<template v-if="entry.visual">
44+
<img
45+
:style="{display:(params.style == 'square')? false : 'none'}"
46+
class="area visual-area"
47+
:src="urlImage(entry,'visual',{{ imWidth }},{{ imHeight }},'crop')"
48+
@error="urlImageResizedOnError(entry,'visual',{{ imWidth }},{{ imHeight }},'crop',{{ firstTokenCrop|json_encode }})"></img>
49+
<div v-if="params.style != 'square'" class="area visual-area"
50+
:style="{color:'blue','background-image': `url('${urlImage(entry,'visual',{{ imWidth }},{{ imHeight }},'crop')}')`}">
51+
</div>
52+
</template>
4553
<div v-else class="area area visual-area placeholder"></div>
4654
</template>
4755

0 commit comments

Comments
 (0)