TxTu Set Image Class
TxTu Set Image Class is a WordPress plugin. The plugin is a filter for images found on your WordPress posts / pages. Before displaying a post or page on your WordPress blog, it will search for images (identified by the <img> tag). It will then remove any height, width or align attributes found on the image. Depending on your setting, it will insert class and id attributes in the images.
Who needs this plugin
Now why would you want to do that you might ask. One reason might be the same reason that I was motivated to create this WordPress plugin. I use a blog editor called Blogdesk. It’s a freely available blog editor with great features and works wonderfully with WordPress especially when uploading posts that contains photos or images. If you also use Blogdesk then you already know how wonderful it is.
But there is one feature that I think can be improved on. When it uploads the images of your posts, it will set the image height and width attributes of the images. It would have been a better feature if I would be able to set a class or id for the image instead of a width and height attribute. Since the Blogdesk software is not open-sourced, I decided to create this plugin that removes the height and width attributes and replace them with class and id attributes. This way I can set their properties in my stylesheet file.
Another reason is if you want to have different properties for images depending on the categories they belong or whether they are the 1st, 2nd, 3rd … image. Because this plugin appends the category name to the class name and uniquely identifies each image using the id attribute, you can uniquely set properties for your images in your WordPress stylesheet file.

Download: txtu-set-img-class.zip
Current Version: 1.0
Updated: January 18, 2008
Size: 9.99 KB
Downloaded: 39 times
Installing the plugin
The procedure for installing the plugin is the same as any Wordpress plugin. Just unzip the file into the /wp-content/plugins/ directory. Then go to the WordPress Admin panel and click on “Plugins”. From the list of plugins look for the plugin named “Set IMG Class”. Click on the “Activate” link to enable the plugin.
Once the plugin is enabled, go to “Options / Image Class”. There are currently two options that you can configure. One is whether you want the plugin to insert a class attribute when it finds an IMG on your posts/pages. The other option is if you want an id attribute inserted into the IMG tags. If you enable the insertion of a class or id attribute, the plugin will check if there is already an existing class or id present on the IMG tags. If it finds them, the plugin will not replace those attributes.
How is it done
As an example, the images actually found on this page have been formatted using CSS stylesheets. Whether or not you enable the options, the plugin will always remove any height, width and align attributes on your images. The removable and replacement of the attributes on the IMG tags only happen before the posts/pages are rendered. They are not saved and your original post will remain intact.
If you enable insertion of class and id attributes, the images will then have a class name in the format “txtu-[categoryname]” while the id attributes will have the format “txtu-[categoryname]-[postid]-[imagenumber]“.
A word of advice
As always, before you do anything to your precious blog, make sure you backup your WordPress installation and data.
If you need help just post a comment here and I’ll get back to you as soon as I can.






Leave a Reply