0

Is possible to assign a default class to the images that are part of a post content? I have a problem with teh layout, this because the attached images insetred inside a post will break my bootstrap layout. I want to assign a default class so the user when add an image into the content will have the class assigned and the layout will not break.

0

As you are using bootstrap you can add img-fluid helper class to images like this.

function example_add_img_class( $class ) {
     
    return $class . ' img-fluid';
     
}
 
add_filter( 'get_image_tag_class', 'example_add_img_class' );

get_image_tag_class filter allows to add custom css class along side WordPress default classes. Read more about the filter here

| improve this answer | |
-1

I guess you seeking of get_image_tag_class filter.

| improve this answer | |
  • 3
    How it's an answer? Edit and add Code example. – Sabbir Hasan Jul 8 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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