WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I upload a large size image inn my wordpress, the image breaks my template width. I have seen some templates which scale the large image's width to the maximum width of the post div. What CSS or code I need to change for that purpose? Thanks.

share|improve this question
up vote 2 down vote accepted

In your functions.php file, you need to define $content_width, which will cause WordPress to scale large-size images, and also embedded videos, accordingly.

e.g. if the width of your content area is 600px:

if ( ! isset( $content_width ) ) {
    $content_width = 600;

You will probably also want to add accompanying CSS, e.g.:

#content img {
    width: auto;
    max-width: 600px;
    height: auto;

That way, when the image is scaled, it will maintain its proportion; rather than merely having its width reduced, the height will also be scaled proportionately.

share|improve this answer

You don't need any CSS, just go to Settings > Media and adjust the Large image size width to that of your post container. You may need to Regenerate Thumbnails after doing that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.