Vee
Vee

Reputation: 1

Adding css classes to single images in wordpress

Is there a way to add css classes or ID's to images in wordpress? Or is there a media library plugin that adds a "css classes" field so you can add a class for that particular image once uploaded?

Cheers!

Upvotes: 0

Views: 2054

Answers (1)

Sunil Dora
Sunil Dora

Reputation: 1472

Try this,

function add_image_class($class){
$class .= ' additional-class';
return $class;
}
add_filter('get_image_tag_class','add_image_class');

or

the_post_thumbnail('thumbnail', array('class' => 'img-responsive'));

Hope this will helps you.

For more information,

Upvotes: 1

Related Questions