Default theme discards CSS class for img tags. What now?

I created a post containing <img class="xyz" src="..." />, but when Discourse renders the post, it puts my image in a lightbox-wrapper and discards my CSS class, so I can’t style it using that class.

Is this a defect in the theme? in Discourse? Is it just something I need to make peace with not being allowed to do? I only want to style certain kinds of images in this particular way and I prefer not to write custom CSS that depends on CSS classes whose names I don’t control.

Thanks.

3 Likes

Hi @jbrains :slight_smile:

Discourse only accepts an array of allowed HTML tags and attributes. Adding an arbitrary class to an element isn’t possible without creating a plugin.

However, if you want to customize an image inside your post, you can put it inside a [wrap] tag or something similar.

Have a look at Customize posts' contents with your own styles

6 Likes

I understand and I did something that I can be satisfied with. Thank you.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.