Minimiser une image si elle est trop grande
Bonjour,
dans le cadre d'un affichage dynamique de ma page, j'ai un tableau construit en javascript qui va contenir des images.
Je charge les images ainsi :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| $(img1Preload).load(function () {
$('#' + selectedTab + "1").css("backgroundImage", "").append(this);
}).error(function () {
// notify the user that the image could not be loaded
}).attr('src', graphs[0].imgPath + "?" + new Date().getTime()).attr('id', 'testjbt');
$(img2Preload).load(function () {
$('#' + selectedTab + "2").css("backgroundImage", "").append(this);
}).error(function () {
// notify the user that the image could not be loaded
}).attr('src', graphs[1].imgPath + "?" + new Date().getTime());
$(img3Preload).load(function () {
$('#' + selectedTab + "3").css("backgroundImage", "").append(this);
}).error(function () {
// notify the user that the image could not be loaded
}).attr('src', graphs[2].imgPath + "?" + new Date().getTime());
$(img4Preload).load(function () {
$('#' + selectedTab + "4").css("backgroundImage", "").append(this);
}).error(function () {
// notify the user that the image could not be loaded
}).attr('src', graphs[3].imgPath + "?" + new Date().getTime()); |
Sachant que les $('#'+selectedTab+i) sont des divs créés en dynamique un peu plus haut.
J'aimerais que mes images ne fassent pas plus de 350 en largeur et 262 en hauteur.
Je n'arrive pas à voir comment réaliser cela.
Quelqu'un aurait-il une idée ou une piste ?
Merci