When I add an image to a post I want it to be in a div e.g. , and I want that to be done automatically, so I don’t have to do that in HTML editor.
I don’t want to use js to accomplish this and by the way I want to know how to automatically add custom classes to a image in a post. Cheers!
4 Answers
By default images already have unique class’s but this depends on your theme. Use firebug and hover over the images and you should see stuff like class="aligncenter size-full wp-image-1525"
.
If you want to change the class or id or alter any attributes of the image you can use the get_image_tag
filter. For example,
add_filter('get_image_tag_class','my_custom_class');
function my_custom_class($class){
$class="my_custom_name";
return $class;
}