WordPress 2.5 includes some code designed to prevent oversized images from breaking up the layout of themes by spilling outside of content areas. The code is found in the media.php file and looks like this:

The important part of the code is this bit:
if ( !empty($GLOBALS['content_width']) ) {
$max_width = $GLOBALS['content_width'];
}
else
$max_width = 500;
What is means is if no global value has been set (either in the WordPress install or in the theme itself) to default to a max width of 500 pixels for any images that are inserted as “full size”.
Here at Crane Factory my current theme will support images up to 600px wide, and that is the size I generally shrink any large files down to before uploading them. Unless I tell WordPress this it will keep shrinking “full size” images to 500px when I insert them in posts. To fix this I simply add create a functions.php file in the folder for my theme and add the following code to it:
$GLOBALS['content_width'] = 600;
I have no other functions.php code so the whole file looks like this:

Now when I insert images 600px or more wide, WordPress will shrink them down to 600px to fit my theme rather than the default 500px.












August 4th, 2008 at 1:11 am
Brilliant!