Skip to content

Commit

Permalink
fix(templates): picto images not right
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflos committed May 27, 2024
1 parent 817f929 commit 1c3dda8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
4 changes: 4 additions & 0 deletions styles/qrcards.css
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@

[data-id="bf_plus"] .BAZ_label {display:none}

.col-md-6 .col-md-4 .bazar-entry-edit-image {
flex-direction: column;
}

/* hide yeswiki interface in print mode, and do some tweaks */
@media print {
@page {
Expand Down
7 changes: 4 additions & 3 deletions templates/bazar/fiche-1400.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"listeListePriseEnMain",
"bf_card_color",
"listeListeTypeCarte",
"bf_picto_boite1",
"imagebf_picto_boite1",
"bf_texte_boite1",
"bf_picto_boite2",
"imagebf_picto_boite2",
"bf_texte_boite2",
"bf_picto_boite3",
"imagebf_picto_boite3",
"bf_texte_boite3",
"bf_url",
"imagebf_image",
Expand Down Expand Up @@ -66,3 +66,4 @@
}
echo $res;
}

42 changes: 14 additions & 28 deletions templates/bazar/qrcards.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,14 @@
use YesWiki\Security\Controller\SecurityController;
use YesWiki\Core\Service\FavoritesManager;

function display($val, $default = '', $checkUrl = false, $valtext = 'default')
function display($img)
{
if ($valtext != 'default' && empty($valtext)) {
return '';
} elseif (!empty($val)) {
if ($checkUrl) {
$headers = @get_headers($val);

// Use condition to check the existence of URL
if ($headers && strpos($headers[0], '200')) {
return $val;
} else {
return '';
}
} else {
return $val;
}
} else {
return $default;
if (!empty($img) && file_exists('files/' . $img)) {
return 'files/' . $img;
}
return false;
}

function f($text)
{
return strip_tags($GLOBALS['wiki']->format($text), '<br>');
Expand Down Expand Up @@ -65,7 +52,6 @@ function displayCard($fiche, $view = 'print')
$thumbheight = 300;
$thumbresize = 'fit';
$imgLogo = !empty($GLOBALS['wiki']->config['card_logo']) ? $GLOBALS['wiki']->config['card_logo'] : 'tools/qrcards/images/metacartes.png';
$defaultMiniIcon = 'tools/qrcards/images/metacartes.png';
if (isset($fiche['imagebf_image']) and is_file('files/' . $fiche['imagebf_image'])) {
$image = '<img loading="lazy" alt="image" src="' . redimensionner_image(
'files/' . $fiche['imagebf_image'],
Expand All @@ -77,16 +63,16 @@ function displayCard($fiche, $view = 'print')
} else {
$image = '<img loading="lazy" alt="logo qrcard" src="' . $imgLogo . '" />';
}
$picto1 = display($fiche['imagebf_picto_boite1'], $defaultMiniIcon, true, $fiche['bf_texte_boite1']);
if (!empty($picto1)) {
$picto1 = !empty($fiche['imagebf_picto_boite1']) ? display($fiche['imagebf_picto_boite1']) : false;
if ($picto1) {
$picto1 = '<img loading="lazy" src="' . $picto1 . '" alt="mini-picto1" />';
}
$picto2 = display($fiche['imagebf_picto_boite2'], $defaultMiniIcon, true, $fiche['bf_texte_boite2']);
if (!empty($picto2)) {
$picto2 = !empty($fiche['imagebf_picto_boite2']) ? display($fiche['imagebf_picto_boite2']) : false;
if ($picto2) {
$picto2 = '<img loading="lazy" src="' . $picto2 . '" alt="mini-picto2" />';
}
$picto3 = display($fiche['imagebf_picto_boite3'], $defaultMiniIcon, true, $fiche['bf_texte_boite3']);
if (!empty($picto3)) {
$picto3 = !empty($fiche['imagebf_picto_boite3']) ? display($fiche['imagebf_picto_boite3']) : false;
if ($picto3) {
$picto3 = '<img loading="lazy" src="' . $picto3 . '" alt="mini-picto3" />';
}
$link = (!empty($fiche['bf_url'])) ? $fiche['bf_url'] : $GLOBALS['wiki']->href('', $fiche['id_fiche']);
Expand Down Expand Up @@ -128,9 +114,9 @@ function displayCard($fiche, $view = 'print')
'picto1' => $picto1,
'picto2' => $picto2,
'picto3' => $picto3,
'textpicto1' => display($fiche['bf_texte_boite1']),
'textpicto2' => display($fiche['bf_texte_boite2']),
'textpicto3' => display($fiche['bf_texte_boite3']),
'textpicto1' => $fiche['bf_texte_boite1'] ?? '',
'textpicto2' => $fiche['bf_texte_boite2'] ?? '',
'textpicto3' => $fiche['bf_texte_boite3'] ?? '',
'longtext' => f($fiche['bf_chapeau']),
'qrcode' => $GLOBALS['wiki']->format('{{qrcode text="' . $link . '"}}'),
'link' => $link,
Expand Down

0 comments on commit 1c3dda8

Please sign in to comment.