Assign custom class to post content images

Is possible to assign a default class to the images that are part of a post content? I have a problem with teh layout, t

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.

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.

Share Improve this question asked Jul 8, 2020 at 10:59 wpnewbiewpnewbie 135 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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

I guess you seeking of get_image_tag_class filter.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742283048a4414843.html

相关推荐

  • Assign custom class to post content images

    Is possible to assign a default class to the images that are part of a post content? I have a problem with teh layout, t

    21小时前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信