View Single Post
Old 26-10-2007, 15:28   #3
Alien
Inactive
 
Alien's Avatar
 
Join Date: Jul 2003
Location: UK
Services: VM Phone, V+, VM 10Mb
Posts: 2,655
Alien is cast in bronzeAlien is cast in bronzeAlien is cast in bronzeAlien is cast in bronze
Alien is cast in bronzeAlien is cast in bronzeAlien is cast in bronzeAlien is cast in bronzeAlien is cast in bronzeAlien is cast in bronzeAlien is cast in bronze
Re: Resize images on page with javascript bookmarklet

Quote:
Originally Posted by Mr_love_monkey View Post
try this
Code:
javascript:(function(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid accumulating integer-rounding error */ image.initialHeight=image.height; image.initialWidth=image.width; image.scalingFactor=1; } image.scalingFactor*=amt; image.width=image.scalingFactor*image.initialWidth; image.height=image.scalingFactor*image.initialHeight; } var i,L=document.images.length; for (i=0;i<L;++i) {if (document.images[i].width>800) zoomImage(document.images[i],.5);} if (!L) alert(%22This page contains no images.%22); })();
if you want a different limit just change the 800
Cheers dude, much appreciated, greeny headed your way. I've changed the limit to 750, & the scaling factor to .75, & bound it to a mouse gesture. Thanks to you adding the limit, if the scaling factor isn't enough to reduce a really big image, I can just use the mouse gesture again without shrinking images that aren't too big. Much appreciated.

Quote:
Originally Posted by Mr_love_monkey View Post
also if you want height taken into account you change just replace the bit with the width with
Code:
(document.images[i].width>800 && document.images[i].height>400)
Height was never an issue, but thanks anyway.
Alien is offline   Reply With Quote