bonjour,
je creer un site d annonce mais la fonction de redimensionnment ne fonctionne pas voici son appel:
1 2 3 4 5 6 7
|
include("fctaffichimage.php");
...
while($image = mysql_fetch_assoc($illustration))
{
$content.='<img alt="" fctaffichimage('.$host.'/uneAnnonce/images/'.$image['up_filename'].',120,100) />';
} |
et la fonction fctaffichimage.php:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| <?php
// ---------------------------------------------------------------------------------------
// fonction de redimensionnement A L'AFFICHAGE
// ---------------------------------------------------------------------------------------
// La FONCTION : fctaffichimage($img_Src, $W_max, $H_max)
// Les parametres :
// - $img_Src : URL (chemin + NOM) de l image Source
// - $W_max : LARGEUR maxi finale ----> ou 0 : largeur libre
// - $H_max : HAUTEUR maxi finale ----> ou 0 : hauteur libre
// ---------------------------------------------------------------------------------------
// Affiche : src="..." width="..." height="..." pour la balise img
// Utilisation :
// <img alt="" fctaffichimage('repimg/monimage.jpg', 120, 100) />
// ---------------------------------------------------------------------------------------
function fctaffichimage($img_Src, $W_max, $H_max) {
echo tesyt2;
if (file_exists($img_Src)) {
echo oui;
// ----------------------------------------------------
// Lit les dimensions de l'image source
$img_size = GetImageSize($img_Src);
$W_Src = $img_size[0]; // largeur source
$H_Src = $img_size[1]; // hauteur source
// ----------------------------------------------------
if(!$W_max) { $W_max = 0; }
if(!$H_max) { $H_max = 0; }
// ----------------------------------------------------
// Teste les dimensions tenant dans la zone
$W_test = round($W_Src * ($H_max / $H_Src));
$H_test = round($H_Src * ($W_max / $W_Src));
// ----------------------------------------------------
// si l image est plus petite que la zone
if($W_Src<$W_max && $H_Src<$H_max) {
$W = $W_Src;
$H = $H_Src;
// sinon si $W_max et $H_max non definis
} elseif($W_max==0 && $H_max==0) {
$W = $W_Src;
$H = $H_Src;
// sinon si $W_max libre
} elseif($W_max==0) {
$W = $W_test;
$H = $H_max;
// sinon si $H_max libre
} elseif($H_max==0) {
$W = $W_max;
$H = $H_test;
// sinon les dimensions qui tiennent dans la zone
} elseif($H_test > $H_max) {
$W = $W_test;
$H = $H_max;
} else {
$W = $W_max;
$H = $H_test;
}
// ----------------------------------------------------
} else { // si le fichier image n existe pas
$W = 0;
$H = 0;
echo non;
}
// ----------------------------------------------------
// AFFICHE les dimensions optimales
echo ' src="'.$img_Src.'" width="'.$W.'" height="'.$H.'"';
}
// Affiche : src="..." width="..." height="..." pour la balise img
// ---------------------------------------------------------------------------------------
?> |
merci de votre aide.
la source de la page:
<tr><td><img alt="" fctaffichimage(http://localhost/idealeparution/uneAnnonce/images/0_090911103733.jpg,120,100) />
l adresse est la bonne, la fonction est bien place j ai fait un echo et je pense que le script ne rentre pas dans la fonction.
Partager