Recadrer || redimensionner des images avec javascript
Bonjour � tous et � toutes,
Encore moi! J'ai fait une petite recherche avant de poster mais n'est aps trouver de solution concr�te sur le Web. Alors si vous avez des liens tout simplement j'en serais ravis.
voici mon code :
Code:
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
|
function redimImage(inImg, inMW, inMH, lienImg) {
var maxWidth = inMW;
var maxHeight = inMH;
var dW = 0;
var dH = 0;
var oImg = new Image();
oImg.src = inImg;
/*
var oLabel = new String();
oLabel.String() = lienImg;
*/
var h = dH = oImg.height;
var w = dW = oImg.width;
if ((h >= maxHeight) || (w >= maxWidth)) {
if ((h >= maxHeight) && (w >= maxWidth)) {
if (h > w) {
dH = maxHeight;
dW = parseInt((w * dH) / h, 10);
} else {
dW = maxWidth;
dH = parseInt((h * dW) / w, 10);
}
} else if ((h > maxHeight) && (w < maxWidth)) {
dH = maxHeight;
dW = parseInt((w * dH) / h, 10);
} else if ((h < maxHeight) && (w > maxWidth)) {
dW = maxWidth;
dH = parseInt((h * dW) / w, 10);
}
}
document.write('<a href="#" onclick="imageLeft(\'' + lienImg + '\'); labelImg(\'' + lienImg + '\');"><img id="' + lienImg + '" src="' + inImg + '" width="' + dW + '" height="' + dH + '" border="0" /></a> <a class="type2" href="#" onclick="imageLeft(\'' + lienImg + '\'); labelImg(\'' + lienImg + '\');">' + lienImg + '</a>');
}; |
L'ensemble du code marche .... le ick! c'est que les images ne s'affiche pas si cela prend trop de temps. J'aimerais savoir comment r�gler le probl�me afin que toute les images s'affiches.
(En bref si ceci prend trop de temps au browser pour afficher les images, il ne les affichera pas (size 0 - 0)).
Merci d'avance