Ресайз картинки jquery

Jake Foley
На сайте с 16.08.2008
Offline
151
1858

Добрый день.

Есть код для ресайза катинки


<script type="text/javascript" src="http://ditio.net/wp-content/uploads/2010/01/jquery-resize.js"></script>
<script type="text/javascript">
$(function(){
$("#pics img").resizeImg({maxHeight: 400, maxWidth: 500 });
});
</script>

После вызывается вот так:

<ul id="pics">

<li><img src=image.jpg></li>
</ul>

Изображение изменяет свой размер после того как полностью загрузилось.

Можно ли как то это обойти, у меня есть значения widht и height еще до начала загрузки изображения.

Можете помочь?

Jake Foley добавил 13.02.2011 в 19:25

Есть еще другой код

<script type="text/javascript">

<!--
{popup_js_code}
var max_width=500;
function adjustImage(init)
{
if(document.getElementById("img_obj").width>max_width)
{
origin_width = document.getElementById("img_obj").width;
document.getElementById("img_obj").width = max_width;
document.getElementById("resized").style.display='';
}
else
if(document.getElementById("img_obj").width<=max_width)
{
if(init==1) origin_width = document.getElementById("img_obj").width;
document.getElementById("img_obj").width = origin_width;
document.getElementById("resized").style.display='none';
}
}
function autoResize(id){
var newheight;
newheight=document.getElementById(id).contentWindow.document.body.scrollHeight;
document.getElementById(id).height= (newheight + 16) + "px";
}
-->
</script>

Jake Foley добавил 13.02.2011 в 22:48

Налеш кроссбраузерное решение.

<img src="8ede17f0.jpg" style="max-width:400px; max-height:400px;height: expression(this.height >= this.width && this.height > 400 ? 400 : true);

width: expression(this.height < this.width && this.width > 400 ? 400 : true);"/>

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий