Bonsoir à tous,
Bon voila je sais ça doit etre super simple mais j'y arrive pas ca me fait n'importe quoi ...
Mon but est simple :
J'ai une image pour laquelle je récupère les dimensions (Width et Height)
A partir de la je veux faire des boucles de telle sorte qu'on obtienne une image ayant une largeur MAX de 485 et/ou une hauteur MAX de 400 :
Le script ci-dessous est utilisé pour afficher les images avec fondu tournant en boucle... j'ai inclu du PHP dedans pour redimensionner les images en live mais ca marche pas
Code :
- <SCRIPT LANGUAGE="JavaScript">
- imgPath = new Array;
- imgWidth = new Array;
- imgHeight = new Array;
- SiClickGoTo = new Array;
- if (document.images)
- {
- <?php
- $query = "SELECT * FROM image WHERE tagged=1";
- $result = mysql_query($query);
- $i=0;
- while ($item = mysql_fetch_array($result))
- {
- $images = $item['fichier'];
- echo "i".$i." = new Image;\n";
- echo "i".$i.".src = 'images/web/".$images."';\n";
- echo "SiClickGoTo[".$i."] = \"#\";\n";
- echo "imgPath[".$i."] = i".$i.".src;\n";
- list($width, $height, $type, $attr) = getimagesize("images/web/$images" );
- if ($width > 485)
- {
- $height = round(485 * $height / $width);
- $width = 485;
- }
- if ($height > 400)
- {
- $width = round(400 * $width / $height);
- $height = 400;
- }
- echo "i".$i.".width = '$width';\n";
- echo "i".$i.".height = '$height';\n";
- echo "imgWidth[".$i."] = i".$i.".width;\n";
- echo "imgHeight[".$i."] = i".$i.".height;\n";
- $i++;
- }
- ?>
- }
- a = 0;
- function ejs_img_fx(img)
- {
- if(img && img.filters && img.filters[0])
- {
- img.filters[0].apply();
- img.filters[0].play();
- }
- }
- function StartAnim()
- {
- if (document.images)
- {
- document.write('<?php echo "$h - $w - $h_n<br>"; ?><IMG HEIGHT=<?php echo $height; ?> WIDTH=<?php echo $width; ?> SRC="images/web/docpix000002.jpg" BORDER=0 ALT=Menu NAME=defil style="filter:progid:DXImageTransform.Microsoft.Fade(MaxSquare=100,Duration=1)">');
- defilimg()
- }
- else
- {
- document.write('<?php echo $h; ?><IMG HEIGHT=<?php echo $height; ?> WIDTH=<?php echo $width; ?> SRC="images/web/docpix000003.jpg" BORDER=0>')
- }
- }
- function ImgDest()
- {
- document.location.href = SiClickGoTo[a-1];
- }
- function defilimg()
- {
- if (a == <?php echo $i; ?> )
- {
- a = 0;
- }
- if (document.images)
- {
- ejs_img_fx(document.defil)
- document.defil.src = imgPath[a];
- document.defil.width = imgWidth[a];
- document.defil.neight = imgHeight[a];
- tempo3 = setTimeout("defilimg()",5000);
- a++;
- }
- }
- </SCRIPT>
|
Merci de votre aide 
Message édité par Odissine le 22-09-2009 à 14:07:08