8 Responses to “Align Image In Post WordPress 2.7”

Comments

Read below or add a comment...

  1. Hi Ah Pek,
    I know you’re a popular man around the WP forums, so I thought I’d see if you can work out the kink in my image-align issue:

    I have tried about EVERY solution I could find on all the forum sites concerning this, but nothing’s worked yet. Here is a prime example of my problem:

    http://www.epochsy.com/2009/01/27/edletwinter08/

    The David Bowie quote is meant to be centered, but obviously, is not. Here is what my style.css currently looks like:

    /*img.alignright { float:right; margin: 0 0 1px 5px; padding: 2px;}

    img.alignleft { float:left; margin: 0 5px 5px 0; padding: 2px;}

    img.aligncenter { float:center; margin: 0 5px 5px 0; padding: 2px;}*/

    /*This works to RIGHT align images, but not centered ones!!!*/

    img.alignleft, div.alignleft {
    float:left;
    margin:2px 2px 2px 0px;
    }
    img.alignright, div.alignright {
    float:right;
    margin:2px 0px 2px 2px;
    }
    img.centered, .aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
    }

    /*img.centered, .aligncenter, div.aligncenter {
    display: block;
    margin-left: auto;
    margin-right: auto;
    }

    img.alignright {
    padding: 4px;
    margin: 0 0 2px 7px;
    display: inline;
    }

    img.alignleft {
    padding: 4px;
    margin: 0 7px 2px 0;
    display: inline;
    }

    .alignright {
    float: right;
    }

    .alignleft {
    float: left;
    }*/

    If you can help me I would be infinitely grateful. I’ve been trying to fix this for about 3-4 hours, and if I can’t fix it by tomorrow night, my head might explode.

    Thanks!

    • Ryan,

      Are you using WordPress 2.7? Some themes simply do not comply but what I can suggest is that you remove all those old image alignment codes and replace them with these

      p img {
      padding: 0;
      max-width: 100%;
      }

      img.centered {
      display: block;
      margin-left: auto;
      margin-right: auto;
      }

      img.alignright {
      padding: 4px;
      margin: 0 0 2px 7px;
      display: inline;
      }

      img.alignleft {
      padding: 4px;
      margin: 0 7px 2px 0;
      display: inline;
      }

      .alignright {
      float: right;
      }

      .alignleft {
      float: left
      }

      Can’t promise anything as like I said, some themes simply do not work with 2.7

      Do save up your old stylesheet before messing with it though.

      I’ll update the ones I have posted above.

  2. Thanks a lot, this fix corrected my issue with the images. I truly appreciate it!!!

  3. I just wanted to tell you – thank you, thank you, thank you for this fix! I was feeling so frustrated with my image alignment after a wordpress upgrade and your code fixed it perfectly after days of searching for a solution. Your time is appreciated! Thanks again!!

  4. Ed

    Code worked a treat, thanks. The theme I am using is really kicking now.

Trackbacks

  1. [...] for visiting!UPDATE: If you are using the new version of WordPress 2.6 and above, check this post: Align Image In WordPress 2.7 A lot of WordPress Themes don’t include the functions to align images, something which I find [...]

  2. Andres Vivas says:

    RT @tweetmeme Align Image In Post WordPress 2.7 | Blog Templates Reviews http://bit.ly/dV3Ag (it took me 4 hours to try to do it by myself)

  3. Costa says:

    Latest update from Blogigs.com – Align Image In Post WordPress 2.7 Read all of it here http://bit.ly/dB8F5v