We Are Communication Architects

Building brand awareness through content creation and community engagement.

July 31st, 2008

Controlling the Max Width of Images Uploaded to WordPress Admin

I was asked the following today in regards to a WordPress site:

Is there any way for me to load a photo into an item and stretch it so that it just fills the column but doesn’t overfill?

My first thought was resize your photo before you upload it. Then my second thought was upload it to Flickr if you want a nice sized version of your photo. But then I got to thinking… is there a way to control this through WordPress? Turns out there is. I may be late to the party on this, or there may be another way to control this so let me know, but here’s what I did. Just added the following line to the functions.php file on the theme:

$GLOBALS['content_width'] = 500;

Where 500 was the widest I wanted the image to go. After doing that it was good to go. Using the “Add media: Add an Image” now within the post and selecting the “Full Size” option will place a photo that’s forced to the max available space within the content pane. Not bad.

About the Author
Nick Gernert leads the Platform Services team that's part of Voce Connect and oversees all web development efforts as well as making sure all those efforts are strategically sound. He is on Twitter as @nickgernert.

Filed in WordPress

Comments are closed.