The discussion revolves around adding an ID or CLASS to an image within a post. DigitalStartup is trying to apply CSS to an image, but the ID or CLASS is being stripped out. Johani explains that only a few attributes are whitelisted for <img> tags and that whitelisting specific classes requires a plugin.
Johani suggests an alternative solution by wrapping the image in a <div> with a custom attribute and targeting it with a CSS selector. However, DigitalStartup finds that the ID is also being stripped out from the <div>.
Johani provides further clarification on the whitelisted markup allowed in the composer and suggests using the anon class added to the <html> tag to selectively show banners to non-logged-in users. DigitalStartup successfully implements this solution, using the following code:
Whitelisting specific classes can be done but would require a plugin.
How often do you plan on using this? You might be able to make something work with a theme component but the implementation will depend on your use case. Can you share a specific example of what you’re trying to do?
for example, you can wrap the image in something like
That file - it is the same one from my earlier post - contains all the whitelisted markup allowed in the composer so have a look around to see what is allowed. Anything not on that list will be stripped out to prevent abuse.
The <html> tag has a CSS class added to it to when the user is not logged in. That class is anon. You can use that class to selectively show the banners. So something like this in your post: