<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Setting Maximum Width For Image In IE6, IE7 &amp; Firefox</title>
	<atom:link href="http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/</link>
	<description>Tips, Tricks &#38; Rants of a Sys Admin</description>
	<lastBuildDate>Tue, 07 Sep 2010 10:05:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: max-width and IE6 &#171; Expression Web Tips</title>
		<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/comment-page-1/#comment-2500</link>
		<dc:creator>max-width and IE6 &#171; Expression Web Tips</dc:creator>
		<pubDate>Fri, 23 Oct 2009 17:10:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattiasgeniar.be/?p=317#comment-2500</guid>
		<description>[...] Setting Maximum Width For Image In IE6, IE7 &amp; Firefox ~ Mattias Geniar [...]</description>
		<content:encoded><![CDATA[<p>[...] Setting Maximum Width For Image In IE6, IE7 &amp; Firefox ~ Mattias Geniar [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/comment-page-1/#comment-2476</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Thu, 01 Oct 2009 19:15:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattiasgeniar.be/?p=317#comment-2476</guid>
		<description>This
my_img {
	max-width: 500px;
	/* Resize the image for IE6 */
	width: expression(this.width &gt; 500 ? 500: true);
}
The code above is simple CSS, that will work for all major browsers to set a maximum width for an image (in this case: 500px).

All you need to do now is set the class on your image:


There are, of course, alternatives as well. You could call a javascript function that will determine the width of your image, and resize accordingly. Here’s the function.

function resizePhoto() {
	if (document.getElementById(&#039;photo_id&#039;)) {
		photo = document.getElementById(&#039;photo_id&#039;);
 
		if (photo.width &gt; 500) {
			photo.width = 500;
		}
	}
}

Is a great piece of code it saved my bacon. I display images uploaded by users. I create a resized one on upload with php so that the thumbs page loads fast But save the orign. for single display. I needed to display at full size up to a limit so small ones were not stretched and big ones did not get to big. This code did the trick Thanks a lot.</description>
		<content:encoded><![CDATA[<p>This<br />
my_img {<br />
	max-width: 500px;<br />
	/* Resize the image for IE6 */<br />
	width: expression(this.width &gt; 500 ? 500: true);<br />
}<br />
The code above is simple CSS, that will work for all major browsers to set a maximum width for an image (in this case: 500px).</p>
<p>All you need to do now is set the class on your image:</p>
<p>There are, of course, alternatives as well. You could call a javascript function that will determine the width of your image, and resize accordingly. Here’s the function.</p>
<p>function resizePhoto() {<br />
	if (document.getElementById(&#8216;photo_id&#8217;)) {<br />
		photo = document.getElementById(&#8216;photo_id&#8217;);</p>
<p>		if (photo.width &gt; 500) {<br />
			photo.width = 500;<br />
		}<br />
	}<br />
}</p>
<p>Is a great piece of code it saved my bacon. I display images uploaded by users. I create a resized one on upload with php so that the thumbs page loads fast But save the orign. for single display. I needed to display at full size up to a limit so small ones were not stretched and big ones did not get to big. This code did the trick Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dennis</title>
		<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/comment-page-1/#comment-2244</link>
		<dc:creator>Dennis</dc:creator>
		<pubDate>Tue, 14 Apr 2009 04:21:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattiasgeniar.be/?p=317#comment-2244</guid>
		<description>Your solution is really great!!! 
It helped me a lot!!</description>
		<content:encoded><![CDATA[<p>Your solution is really great!!!<br />
It helped me a lot!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Orlando</title>
		<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/comment-page-1/#comment-2242</link>
		<dc:creator>Orlando</dc:creator>
		<pubDate>Tue, 07 Apr 2009 20:39:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattiasgeniar.be/?p=317#comment-2242</guid>
		<description>You can avoid guessing when the image has been loaded puting the call to the function in the window load event:

window.onload = function(){
    resizePhoto();
}</description>
		<content:encoded><![CDATA[<p>You can avoid guessing when the image has been loaded puting the call to the function in the window load event:</p>
<p>window.onload = function(){<br />
    resizePhoto();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christina</title>
		<link>http://mattiasgeniar.be/2008/08/22/setting-maximum-width-for-image-in-ie6-ie7-firefox/comment-page-1/#comment-1064</link>
		<dc:creator>Christina</dc:creator>
		<pubDate>Sun, 07 Sep 2008 20:40:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.mattiasgeniar.be/?p=317#comment-1064</guid>
		<description>Your blog helped me fix my width problem, however, the css is even simpler than you described it:
it is not necessary to set a class on the photos, just to style the img tag 
&lt;code&gt;
img {
	max-width: 500px;
	/* Resize the image for IE6 */
	width: expression(this.width &gt; 500 ? 500: true);
}
&lt;/code&gt;
This will resize EVERY image on the page, so if that is not desired, class it is.

/Christina</description>
		<content:encoded><![CDATA[<p>Your blog helped me fix my width problem, however, the css is even simpler than you described it:<br />
it is not necessary to set a class on the photos, just to style the img tag<br />
<code><br />
img {<br />
	max-width: 500px;<br />
	/* Resize the image for IE6 */<br />
	width: expression(this.width &gt; 500 ? 500: true);<br />
}<br />
</code><br />
This will resize EVERY image on the page, so if that is not desired, class it is.</p>
<p>/Christina</p>
]]></content:encoded>
	</item>
</channel>
</rss>
