Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking for a code in j-query , regarding image size reducing its size at different place on the same website (e.g. if you see facebook, the profile image of individual at left top panel is big and same image is reduced in size when this image appears with comment box) .
Posted
Updated 28-Mar-12 19:27pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Mar-12 13:17pm    
Do you mean file size, image size, or both?
--SA
Sergey Alexandrovich Kryukov 28-Mar-12 13:18pm    
Do you have anything on server side?
--SA
[no name] 29-Mar-12 1:25am    
no i mean image size, if you see facebook, the profile image of individual at left top panel is big and same image is reduced in size when his image appears with comment box

1 solution

You can simply do
JavaScript
myImage.attr("width", newWidth);
//or
myImage.attr("height", newHeight);
where myImage is the DOM object corresponding to you img element. If you change only width or only height in both JavaScript code in and in HTML (or better yet, neither width nor height is defined in HTML), the same aspect ratio is preserved; it is defined by the "natural" dimensions of the image.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900