Image auto resize not working?
-
My projects in asp.net that show images do not resize in the browser if they are too big for the browser window. Most websites that I go to automatically resize the image if it's too big. So it's not the settings in the browser. Does anyone know why this happens or how to fix it? Thanks in advance - Dave
-
My projects in asp.net that show images do not resize in the browser if they are too big for the browser window. Most websites that I go to automatically resize the image if it's too big. So it's not the settings in the browser. Does anyone know why this happens or how to fix it? Thanks in advance - Dave
Automatic image resizing to fit the window is indeed a browser setting. For Firefox it is under Tools-->Options-->Advanced-->Browsing. For IE it is under Tools-->Internet Options-->Advanced-->Multimedia. You can, however, control the image size using the CSS height[^] and width[^] properties. The first possible solution that comes to mind would be to handle the javascript
onload
andresize
events to sniff the browser dimentions and set the image size accordingly. Hope that helps. :) --Jesse -
Automatic image resizing to fit the window is indeed a browser setting. For Firefox it is under Tools-->Options-->Advanced-->Browsing. For IE it is under Tools-->Internet Options-->Advanced-->Multimedia. You can, however, control the image size using the CSS height[^] and width[^] properties. The first possible solution that comes to mind would be to handle the javascript
onload
andresize
events to sniff the browser dimentions and set the image size accordingly. Hope that helps. :) --JesseJesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave
-
Jesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave
I nearly forgot... The icon in the bottom right corner that usually appears with oversized images does not appear! The browser must think that it's something else because the src attribute of the image tag points to an aspx page.
-
Jesse Thanks for the reply. I hadn't really thought about doing it manually but it would be a possible solution. I just can't understand why pictures from other sites resize automatically whereas by pictures don't. I'm using asp.net to render an image programatically. Here is a picture from a normal website that resises automatically http://www.barkshire.co.uk/bikes/images/Norton18_1931/NortonMod18_1931_RL_low.jpg[^] and here is one from the dot net project that doesn't http://www.barkshire.co.uk/travel/ShowSingle.aspx?URL=Angkor_tree1.jpg[^] There must be something in the way that its streamed down. I wish that there was a client side method that would call the automatic resize. Dave
The reason is: The first link is not a web page (it is a .jpg file, not .html) and the second link is a we page (it is .aspx file, not .jpg). Your browser automatically resizes image files to fit. The browser must be told by your web page how the image should be displayed.
-
I nearly forgot... The icon in the bottom right corner that usually appears with oversized images does not appear! The browser must think that it's something else because the src attribute of the image tag points to an aspx page.
Yup... Scott nailed it. Remember that it is a browser setting, not an HTML/ASP.NET behavior to resize images. The browser appears to apply the behavior based on the file extension, rather then the conten headers. As it is a browser setting, controlled by the users, you may want to be careful depending on it. Some users, such as myself, turn the feature off. If you need to depend on it, you'll have to scale the image manually. Hope that helps. :) --Jesse
-
The reason is: The first link is not a web page (it is a .jpg file, not .html) and the second link is a we page (it is .aspx file, not .jpg). Your browser automatically resizes image files to fit. The browser must be told by your web page how the image should be displayed.
Thanks for the help from you all. it does make sense now that i think about it more. I have only one final question. Does anyone have a snippet of javascript or asp.net code that will resize the image?