-
The Previous Posting
« WordPress, Fatal error: Allowed memory size of 33554432 bytes exhausted -
The Next Posting
Enabling HTML in Magento Terms and Conditions »
How Do I Specify a Class For IMG Inserted With Visual Editor…

The following is in response to a question on WordPress.org. We’ve become extremely proficient with wordpress in the past few years, and we’re always coming up with innovative ways of using this amazing product. We try to post most all our fixes, hacks, and tricks, in the hopes that it will prove useful to someone. Hopefully this will be no different.
When you say Visual Editor, are you saying you don’t have the ability to choose HTML view in your posts? If so thats a whole nother problem. But if you do have HTML view, read on.
I don’t know why no ones answered this yet. Its actually really simple. All you need to do is style your images in you style sheet. Here’s a few examples.
If you don’t have an img class setup in your style sheet, you should first add something like…
1 2 3 4 5
.entrybody img{ margin:0; padding:0; border:none; }
Note, The div class on my posts is entrybody, yours may be different. Also this will style every image, in all your posts.
Next to style your images differently, ie. float left, float right, etc. You’ll want to use a class selector, as follows.…
1 2 3 4 5 6
.entrybody img.leftfloat{ margin:0 10px; padding:0; border:none; float:left; }
Now to call to this class selector in your post, your img tag will look something like this.
1
<img class="leftfloat" src="http://www.yoursite.com/wp-content/uploads/2009/08/myprettyimage-150x150.png" alt="MyPrettyImage" title="MyPrettyImage" width="150" height="150" />
I realize the original poster asked for this almost a year ago, but I’m sure it will still prove helpful to someone.