From c22b589df3a8008ade86a41696d383a917feb5fd Mon Sep 17 00:00:00 2001
From: Cerdic <cedric@yterium.com>
Date: Tue, 10 Dec 2019 10:20:07 +0100
Subject: [PATCH] preciser la taille de l'icone qu'on utilise en background,
 car en SVG elle n'est pas forcement par defaut bonne

---
 ecrire/inc/filtres.php      | 13 ++++++++++---
 ecrire/inc/pipelines.php    |  2 +-
 ecrire/inc/presentation.php |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php
index fc1fe7c6a3..ef9180977b 100644
--- a/ecrire/inc/filtres.php
+++ b/ecrire/inc/filtres.php
@@ -3347,10 +3347,17 @@ function http_img_pack($img, $alt, $atts = '', $title = '', $options = array())
  *
  * @param string $img
  * @param string $att
+ * @param string $size
  * @return string
  */
-function http_style_background($img, $att = '') {
-	return " style='background" . ($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";'";
+function http_style_background($img, $att = '', $size=null) {
+	if ($size and is_numeric($size)){
+		$size = trim($size) . "px";
+	}
+	return " style='background" .
+		($att ? "" : "-image") . ": url(\"" . chemin_image($img) . "\")" . ($att ? (' ' . $att) : '') . ";"
+		. ($size ? "background-size:{$size};" : '')
+		. "'";
 }
 
 /**
@@ -3916,7 +3923,7 @@ function prepare_icone_base($type, $lien, $texte, $fond, $fonction = "", $class
 		// 2 images pour composer l'icone : le fond (article) en background,
 		// la fonction (new) en image
 		$icone = http_img_pack($fonction, $alt, "width='$size' height='$size'\n" .
-			http_style_background($fond));
+			http_style_background($fond, '', $size));
 	} else {
 		$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
 	}
diff --git a/ecrire/inc/pipelines.php b/ecrire/inc/pipelines.php
index 412472fab2..41ac32b8dd 100644
--- a/ecrire/inc/pipelines.php
+++ b/ecrire/inc/pipelines.php
@@ -199,7 +199,7 @@ function f_admin($texte) {
 	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) {
 		include_spip('inc/filtres'); // pour http_img_pack
 		$x = "<div class='spip-previsu' "
-			. http_style_background('preview-32.png')
+			. http_style_background('preview-32.png', '', 32)
 			. ">"
 			. _T('previsualisation')
 			. "</div>";
diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php
index fc3e592839..41ed6dd24a 100644
--- a/ecrire/inc/presentation.php
+++ b/ecrire/inc/presentation.php
@@ -61,7 +61,7 @@ function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "",
 			// 2 images pour composer l'icone : le fond (article) en background,
 			// la fonction (new) en image
 			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
-				http_style_background($fond, "no-repeat center center"));
+				http_style_background($fond, "no-repeat center center", $size));
 		} else {
 			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
 		}
-- 
GitLab