Skip to content
Extraits de code Groupes Projets
Valider 0737cbad rédigé par Fil's avatar Fil
Parcourir les fichiers

ne pas retailler des images si la dimension "destination" est proche de la...

ne pas retailler des images si la dimension "destination" est proche de la dimension actuelle, ou si l'image est déjà petite. Le navigateur peut faire une partie du travail tout de même...

NB: si c'est gênant dans certains cas, on peut ajouter une option pour "forcer" la création de l'image.
parent ffecd0fd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -182,7 +182,8 @@ function image_ratio ($srcWidth, $srcHeight, $maxWidth, $maxHeight) { ...@@ -182,7 +182,8 @@ function image_ratio ($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
$destWidth = $maxWidth; $destWidth = $maxWidth;
$destHeight = $srcHeight/$ratioWidth; $destHeight = $srcHeight/$ratioWidth;
} }
return array (ceil($destWidth), ceil($destHeight)); return array (ceil($destWidth), ceil($destHeight),
max($ratioWidth,$ratioHeight));
} }
function creer_vignette($image, $maxWidth, $maxHeight, $format, $destdir, $destfile, $process='AUTO', $force=false, $test_cache_only = false) { function creer_vignette($image, $maxWidth, $maxHeight, $format, $destdir, $destfile, $process='AUTO', $force=false, $test_cache_only = false) {
...@@ -471,22 +472,31 @@ function reduire_image_logo($img, $taille = -1, $taille_y = -1) { ...@@ -471,22 +472,31 @@ function reduire_image_logo($img, $taille = -1, $taille_y = -1) {
if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) { if (eregi("(.*)\.(jpg|gif|png)$", $logo, $regs)) {
if ($i = cherche_image_nommee($regs[1], array($regs[2]))) { if ($i = cherche_image_nommee($regs[1], array($regs[2]))) {
list(,$nom,$format) = $i; list(,$nom,$format) = $i;
$suffixe = '-'.$taille.'x'.$taille_y; if ($taille_origine = @getimagesize($logo)) {
$preview = creer_vignette($logo, $taille, $taille_y, $format, ('cache'.$suffixe), $nom.$suffixe); list ($destWidth,$destHeight, $ratio) = image_ratio(
if ($preview) { $taille_origine[0], $taille_origine[1], $taille, $taille_y);
$vignette = $preview['fichier'];
$width = $preview['width']; // Si la taille n'est pas tres differente, laisser le browser
$height = $preview['height']; // faire la reduction
if ($ratio >= 2
if (!_DIR_RESTREINT) AND max($taille_origine[0], $taille_origine[1]) > 50) {
$date = '?date='.$preview['date']; $suffixe = '-'.$destWidth.'x'.$destHeight;
return "<img src='$vignette$date' width='$width' height='$height'$attributs />"; $preview = creer_vignette($logo, $taille, $taille_y,
} $format, ('cache'.$suffixe), $nom.$suffixe);
else if ($taille_origine = @getimagesize($logo)) { }
list ($destWidth,$destHeight) = image_ratio($taille_origine[0], $taille_origine[1], $taille, $taille_y);
if (!_DIR_RESTREINT) if (!$preview) {
$date = '?date='.filemtime($logo); if (!_DIR_RESTREINT)
return "<img src='$logo$date' width='$destWidth' height='$destHeight'$attributs />"; $date = '?date='.filemtime($logo);
return "<img src='$logo$date' width='$destWidth' height='$destHeight'$attributs />";
} else {
$vignette = $preview['fichier'];
$width = $preview['width'];
$height = $preview['height'];
if (!_DIR_RESTREINT)
$date = '?date='.$preview['date'];
return "<img src='$vignette$date' width='$width' height='$height'$attributs />";
}
} }
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter