Browse Source

Début du chantier de compatibilité PHP 8.1

master v10.0.0
ARNO* 2 months ago
parent
commit
e72718f235
  1. 27
      image_responsive_fonctions.php
  2. 4
      image_responsive_options.php
  3. 2
      paquet.xml

27
image_responsive_fonctions.php

@ -173,23 +173,23 @@ function _image_responsive($img, $taille = -1, $lazy = 0, $vertical = 0, $medias
else $p[$i]["h"] = $regs[3];
$p[$i]["f"] = $regs[5];
$p[$i]["z"] = $regs[7];
if (isset($regs[5])) $p[$i]["f"] = $regs[5];
if (isset($regs[7])) $p[$i]["z"] = $regs[7];
// Gérer les dimensions en pourcentages
preg_match(",([0-9\.]+)\%$,", $regs[1], $regs_l);
preg_match(",([0-9\.]+)\%$,", $regs[3], $regs_h);
if ($regs_l[1] > 0 OR $regs_h[1] > 0) {
if ($regs_l[1] > 0) $p[$i]["l"] = $l * $regs_l[1] / 100;
if ((isset($regs_l[1]) && $regs_l[1] > 0) OR (isset($regs_h[1]) && $regs_h[1] > 0)) {
if (isset($regs_l[1]) && $regs_l[1] > 0) $p[$i]["l"] = $l * $regs_l[1] / 100;
else $p[$i]["l"] = $l;
if ($regs_h[1] > 0) $p[$i]["h"] = $h * $regs_h[1] / 100;
if (isset($regs_h[1]) && $regs_h[1] > 0) $p[$i]["h"] = $h * $regs_h[1] / 100;
else $p[$i]["h"] = $h;
}
if (!$regs[5]) $p[$i]["f"] = "center";
if (!$regs[7]) $p[$i]["z"] = 1;
if (!isset($regs[5])) $p[$i]["f"] = "center";
if (!isset($regs[7])) $p[$i]["z"] = 1;
}
}
}
@ -440,10 +440,11 @@ function _image_responsive($img, $taille = -1, $lazy = 0, $vertical = 0, $medias
if ($vertical == 0) {
if (count($p) == 1 && $p[1]["l"]>0) $r = ($p[1]["h"] / $p[1]["l"]) * 100;
else if (count($p) == 0 && $l > 0) $r = (($h / $l) * 100);
$aff_r = "";
if ($r) {
$aff_r = "padding-bottom:$r%";
}
$img = "<picture style='padding:0;$aff_r' class='conteneur_image_responsive_h$nom_class'>$sources$img</picture>";
$img = "<picture style='padding:0;$aff_r' class='conteneur_image_responsive_h$nom_class'>$sources$img</picture>";
} else {
if ($l > 0) {
$r = (($h / $l) * 100);
@ -634,7 +635,7 @@ function background_responsive($src, $taille = 120, $lazy = 0, $align = "focus")
$h = hauteur($src);
$mtime = filemtime($src);
$ins .= " data-mtime='$mtime'";
$ins = " data-mtime='$mtime'";
$img = $src;
@ -644,8 +645,8 @@ function background_responsive($src, $taille = 120, $lazy = 0, $align = "focus")
$ins .= " data-italien-l='$l'";
$ins .= " data-italien-h='$h'";
$srcp = image_proportions($srcp, 3, 4, $align);
$srcp = image_reduire_net($src, 0, 2400);
$srcp = image_proportions($src, 3, 4, $align);
$srcp = image_reduire_net($srcp, 0, 2400);
$srcp = extraire_attribut($srcp, "src");
$lp = largeur($srcp);
$hp = hauteur($srcp);
@ -699,7 +700,7 @@ function background_responsive($src, $taille = 120, $lazy = 0, $align = "focus")
if ($taille_defaut == 0) $src = find_in_path("rien.gif");
if ($lazy == 1) $ins .= " data-lazy='lazy'";
if ($class) $ins .= " class='$class'";
if (isset($class)) $ins .= " class='$class'";
if (count($tailles) > 1) {
sort($tailles);
@ -786,7 +787,7 @@ function background_responsive($src, $taille = 120, $lazy = 0, $align = "focus")
}
}
if (!isset($links)) $links = "";
$ins .= " style='" . $style_align . $links . "background-image:url($src)'";
return $ins;

4
image_responsive_options.php

@ -72,6 +72,10 @@ function image_reduire_net($source, $taille = 0, $taille_y=0, $dpr=0, $forcer_fo
// chercher un cache
// utiliser le cache ?
$maxWidth = 0; // ??
$maxHeight = 0; // ??
if (!file_exists($destination) OR @filemtime($destination) < @filemtime($image)) {
$creation = true;
// calculer la taille

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="image_responsive"
categorie="multimedia"
version="9.7.3"
version="10.0.0"
etat="stable"
logo="prive/themes/spip/images/image_responsive-32.png"
compatibilite="[3.0.0;4.1.*]"

Loading…
Cancel
Save