![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to Width"> .... How can I solve this problem ? |
#3
| |||
| |||
|
|
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to Width"> .... How can I solve this problem ? |

|
As a second best solution I could accept if I could write percentage values: IMG SRC=..... WIDTH=50% HEIGHT=50% but this doesn't work too. Wladimir |
#4
| |||
| |||
|
|
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to Width"> .... |
#5
| |||
| |||
|
|
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to Width"> .... How can I solve this problem ? |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. snip |
#8
| |||
| |||
|
|
While the city slept, Wladimir Borsov <wladimirb (AT) gmx (DOT) net> feverishly typed: As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to Width"> .... You can use a server-side solution, such as PHP to do the maths. Off the top of my head, if you know the original image width and heght (if not, no problems as you can get them using PHP) something like the following should work; ? php $desiredwidth = 70; $originalwidth = 100; // replace originalwidth and originalheight with whatever the image dimensions are... $originalheight = 200; // ... or find a better way of getting them! $ratio = $originalwidth / $desiredwidth; $desiredheight = $originalheight / $ratio; print("<img src=\"whatever.jpg\" width=\"$desiredwidth\" height=\"$desiredheight\" alt=\"whatever\">\n"); ? I haven't thoroughly checked this, so the maths may be wrong! But it still shows a way to do it. Remember, though, that if an original image is smaller than 70 pixels wide, then this may result in distortion of the image as it will be stretched. Remember also that this is a bad way to make thumbnails of large images, as the full size image file still has to be loaded, regardless of how small you are making it appear on the screen. |
#9
| |||
| |||
|
|
Wladimir Borsov wrote: What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. snip I'm not sure about browser compatibility, this works on my IE6, Netscape 7.1, Firefox 0.8: |
|
function resizepics(w,h){ var p = document.getElementsByTagName('img'); for (var i=0; i<p.length; i++){ p[i].style.width=w; p[i].style.height=h; } } Mike |
#10
| |||
| |||
|
|
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. |
![]() |
| Thread Tools | |
| Display Modes | |
| |