Amit Bhawani Blog

Stay Updated!

Powered by Genesis

You are here: Home / Wordpress Guide / Auto Shrink Posted Images to Maximum Theme Width

Auto Shrink Posted Images to Maximum Theme Width

April 29, 2009 by Amit Bhawani

If you are using wordpress blogs, then you are familiar with the default theme which is a theme full of features, though its not liked by many because of the looks. In the Default WordPress theme whenever you upload any images of any width , they are automatically resized to the theme’s maximum width, not breaking the whole blog and the sidebars. This kind of feature is really required when you are adding multiple images and are looking for perfect looking blog.

When you use other available wordpress themes, then there are chances that you will get problems with the images section because the themes are broken when the size of image exceeds the current theme’s content section width. Any solution for this using wordpress plugins? No there is no real quick solution for this because most wordpress themes are simply coded and the theme developers dont add code for automatically resizing the images added in the content section. The plugins available on the web only work for images which are hosted in your server and do not support for the images which are hosted somewhere.

Solution for Automatically Resizing Images :
You need to access your style.css file located in the themes folder and add the following code –

.post img {
max-width: 530px;
width: expression(this.width > 530 ? 530: true);
}

Generally in your stylesheet the content part is denoted by .post but depending on the theme it can be .post, .content, .center etc and you need to trace the same and add the above code somewhere in your file. Once saved, it starts working and resizes all the images to the given width/size dimensions.

Image Auto Resize Properties

One of my image posted in this blog was of the size – 603px × 136px but it got Automatically scaled to 530px × 120px , which means that it resizes the images to the given width and height respectively. You need to find the maximum width of the content part of your blog and save the dimensions in the above given code.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Related

About

My name is Amit Bhawani and here I like to share my internet/tech experience with my online readers. You can follow me on Twitter, Facebook & Instagram at @AmitBhawani I am also the Editor-in-Chief of PhoneRadar & Master Gadgets

About Amit Bhawani

My name is Amit Bhawani and here I like to share my internet/tech experience with my online readers. You can follow me on Twitter, Facebook & Instagram at @AmitBhawani

Comments

  1. Nelson says

    May 10, 2009 at 8:21 am

    Thanks.
    Thats a great tweak.

  2. Nelson says

    May 10, 2009 at 8:31 am

    Hello Amit.
    I wanted the image to be small so I changed 530 to 450.
    But now my image shrinks in width only,height remains same.
    I want the image to preserve ratio.
    Here is my problem
    http://i44.tinypic.com/24neat0.jpg

  3. Amit Bhawani says

    May 10, 2009 at 10:11 am

    Hey generally , it would resize both the sides mainly based on the width of the images. What is the location where you had installed this?

  4. Nelson says

    May 10, 2009 at 1:37 pm

    There are three .css files
    style.css,style_ie6.css and style_ie.css
    I have added the code in .css at the end.

  5. ashish says

    July 22, 2010 at 6:26 pm

    thnx fr d info..
    u motivate young bloggers with such articles..

  6. Babaji M P says

    July 25, 2010 at 2:40 pm

    Original image size was 600 x 800

    I changed to a new theme which has a content width of 450px
    Implemented the above max width solution,

    But the image result was 450 x 800,
    Instead of 450 x 600 px.

    Any suggestions ?

    • Amit Bhawani says

      July 25, 2010 at 3:11 pm

      The code will automatically resize based on the size you set in the css stylesheet file. There are three locations where the the size should be set which is to be adjusted at 450px which is your requirement.

Timeline

Check out Just EV Tweets by @amitbhawani

Recommended To Read

  • How to Find your WiFi Signal Strength & Dead spots in your Home – Best Apps
  • The Wuhan Corona Virus Effect in India – How to Stay Safe
  • This Blogger Lost 25Kgs with this Secret Strategy that Includes a Fitness Tracker
  • Making Money on YouTube, MCN, Useful Tools, Tips & Success Stories
  • The #JaguarPerformance Experience that was Mind Blowing