Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add a CSS class "myimg" to every image both inside and outside of a post. What is the best way to approach this?

share|improve this question
add comment

2 Answers

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

moreinfo to click here

share|improve this answer
add comment

Try to use this j query function like this in header file

$(document).ready(function() {
 $("img").addClass("myimg")
});
share|improve this answer
    
is there a way to do this via PHP or a WP function rather than JS? –  manc Aug 3 '13 at 9:59
    
The better way is not php or wordpress for all images. –  Bindiya Patoliya Aug 3 '13 at 10:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.