From dc1fc5e684c53b498530479d619de6e260cc370d Mon Sep 17 00:00:00 2001
From: RealET <realet@noreply.git.spip.net>
Date: Tue, 12 Jul 2022 15:13:11 +0200
Subject: [PATCH] fix : il ne faut pas contraindre la taille des SVG
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

(et plus généralement des images vectorielles)

Co-authored-by: RealET <real3t@gmail.com>
Refs: https://git.spip.net/spip/medias/pulls/4893
Co-authored-by: RealET <realet@noreply.git.spip.net>
Co-committed-by: RealET <realet@noreply.git.spip.net>
---
 inc/verifier_taille_document_acceptable.php | 33 +++++++++++----------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/inc/verifier_taille_document_acceptable.php b/inc/verifier_taille_document_acceptable.php
index 37226e05..33b40885 100644
--- a/inc/verifier_taille_document_acceptable.php
+++ b/inc/verifier_taille_document_acceptable.php
@@ -39,22 +39,25 @@ function inc_verifier_taille_document_acceptable_dist(&$infos, $is_logo = false)
 		}
 	} // si c'est une image
 	else {
-		if ($is_logo) {
-			$max_width = (defined('_LOGO_MAX_WIDTH') and _LOGO_MAX_WIDTH) ? _LOGO_MAX_WIDTH : null;
-			$max_height = (defined('_LOGO_MAX_HEIGHT') and _LOGO_MAX_HEIGHT) ? _LOGO_MAX_HEIGHT : null;
-			$min_width = (defined('_LOGO_MIN_WIDTH') and _LOGO_MIN_WIDTH) ? _LOGO_MIN_WIDTH : null;
-			$min_height = (defined('_LOGO_MIN_HEIGHT') and _LOGO_MIN_HEIGHT) ? _LOGO_MIN_HEIGHT : null;
-		}
-		else {
-			$max_width = (defined('_IMG_MAX_WIDTH') and _IMG_MAX_WIDTH) ? _IMG_MAX_WIDTH : null;
-			$max_height = (defined('_IMG_MAX_HEIGHT') and _IMG_MAX_HEIGHT) ? _IMG_MAX_HEIGHT : null;
-			$min_width = (defined('_IMG_MIN_WIDTH') and _IMG_MIN_WIDTH) ? _IMG_MIN_WIDTH : null;
-			$min_height = (defined('_IMG_MIN_HEIGHT') and _IMG_MIN_HEIGHT) ? _IMG_MIN_HEIGHT : null;
-		}
+		// Ne pas contraindre les dimensions des images vectorielles, ça n'a pas de sens
+		if ($infos['type_image'] !== 'svg') {
+			if ($is_logo) {
+				$max_width = (defined('_LOGO_MAX_WIDTH') and _LOGO_MAX_WIDTH) ? _LOGO_MAX_WIDTH : null;
+				$max_height = (defined('_LOGO_MAX_HEIGHT') and _LOGO_MAX_HEIGHT) ? _LOGO_MAX_HEIGHT : null;
+				$min_width = (defined('_LOGO_MIN_WIDTH') and _LOGO_MIN_WIDTH) ? _LOGO_MIN_WIDTH : null;
+				$min_height = (defined('_LOGO_MIN_HEIGHT') and _LOGO_MIN_HEIGHT) ? _LOGO_MIN_HEIGHT : null;
+			}
+			else {
+				$max_width = (defined('_IMG_MAX_WIDTH') and _IMG_MAX_WIDTH) ? _IMG_MAX_WIDTH : null;
+				$max_height = (defined('_IMG_MAX_HEIGHT') and _IMG_MAX_HEIGHT) ? _IMG_MAX_HEIGHT : null;
+				$min_width = (defined('_IMG_MIN_WIDTH') and _IMG_MIN_WIDTH) ? _IMG_MIN_WIDTH : null;
+				$min_height = (defined('_IMG_MIN_HEIGHT') and _IMG_MIN_HEIGHT) ? _IMG_MIN_HEIGHT : null;
+			}
 
-		$res = medias_verifier_largeur_hauteur_image($infos, $max_width, $max_height, $min_width, $min_height);
-		if ($res !== true) {
-			return $res;
+			$res = medias_verifier_largeur_hauteur_image($infos, $max_width, $max_height, $min_width, $min_height);
+			if ($res !== true) {
+				return $res;
+			}
 		}
 
 		if ($is_logo) {
-- 
GitLab