Title: Image class
Last modified: August 18, 2016

---

# Image class

 *  [Manish](https://wordpress.org/support/users/nims/)
 * (@nims)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/image-class/)
 * Hi, I think there shud be an option in admin to select a class to float the image
   right or left for the images in posts where we click Send to Editor button. Something
   like Class: o Float right
    o Float left o Custom class img_post ( this we can
   put in our css file )

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Lorelle](https://wordpress.org/support/users/lorelle/)
 * (@lorelle)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/image-class/#post-523858)
 * Is there such a class in your WordPress Theme’s stylesheet (styles.css)? Look
   there. If it isn’t, then you will need to add it. See [Wrapping Text Around Images](http://codex.wordpress.org/Wrapping_Text_Around_Images)
   and [Using Images](http://codex.wordpress.org/Using_Images) in the WordPress 
   Codex, the online manual.
 *  Thread Starter [Manish](https://wordpress.org/support/users/nims/)
 * (@nims)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/image-class/#post-523880)
 * Thanks for the links but what I wanted to convey was something different. I understand
   we can have different classes in style.css and call them in the img tags whereever
   required. But that has to be done manually, editing each img tag in the post 
   after pressing “Send it to Editor” button and writing class=”someclass” in them.
 * I just wanted a simple addon so that this option can appear in the iframe where
   we select the thumbnail option etc. foe the image. So that when the button “send
   to editor” is pressed we have an img tag with class attribute already displayed.
   The options can be as described in my first message.
 *  Thread Starter [Manish](https://wordpress.org/support/users/nims/)
 * (@nims)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/image-class/#post-524091)
 * Since I didnt get any response, I thought of playing around with some PHP code
   myself. ( I am using WP 2.1 )
    To some extent I managed to satisfy myself by 
   making “Send to editor” button automatically add class=”imgleft” to the img tag
   it inserts in the post.
 * To do this, I opened the upload-js.php file ( its in wp-admin folder ) and inserted
   class=’imgleft’ ( note single quotes ) in the 3 <img tags just before they close
   i.e />
    Here is how they looked after modifications. h += “<img src='” + ( this.
   currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + “‘ alt
   ='” + this.currentImage.title + “‘ width='” + this.currentImage.width + “‘ height
   ='” + this.currentImage.height + “‘ class=’imgleft’ />”;
 * h += “<img src='” + ( this.currentImage.thumb ? this.currentImage.thumb : this.
   currentImage.src ) + “‘ alt='” + this.currentImage.title + “‘ width='” + this.
   currentImage.width + “‘ height='” + this.currentImage.height + “‘ class=’imgleft’/
   >”;
 * h += “<img src='” + ( ‘thumb’ == display ? ( this.currentImage.thumbBase + this.
   currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) )
   + “‘ alt='” + this.currentImage.title + “‘ class=’imgleft’ />”;
 * Now add class imgleft in the style.css file ( or whatever css file u r using )
 * Upload it to the proper folders and thats it. Do make backup of these files before
   making any changes.
 * Now when you insert an image by clicking “Send to Editor” button you will see
   class=”imgleft” attribute already added.
 * Now if someone can help me in adding an option (radio buttons ) to select the
   class I want to add in this tag
 *  [chaz7979](https://wordpress.org/support/users/chaz7979/)
 * (@chaz7979)
 * [19 years ago](https://wordpress.org/support/topic/image-class/#post-524248)
 * I agree that this option needs to be done. That being said, I can probably get
   about as far as you did with the code. I would hate to mess around with the framed
   send to editor stuff.
 * I could probably go in and edit the functions that left and right align text 
   but as soon I edit that to have it insert imgleft and imgright I will probably
   need that function to align text or something.
 * Also…even if I did that, would it still string the code out when it is posted?
 *  [tri-fusion](https://wordpress.org/support/users/tri-fusion/)
 * (@tri-fusion)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/image-class/#post-524257)
 * Thanks nims

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Image class’ is closed to new replies.

 * In: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
 * 5 replies
 * 4 participants
 * Last reply from: [tri-fusion](https://wordpress.org/support/users/tri-fusion/)
 * Last activity: [18 years, 11 months ago](https://wordpress.org/support/topic/image-class/#post-524257)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
