Allow Self-Closing <img /> tag in HTMLEditor Field

Silverstripe Version: 4.11

Question: How to Allow Self-Closing tag in HTMLEditor Field

We have a shortcode with inner HTML content, however the parser does not recognize the inner content when an image is inside. I believe the issue is with the tag not self-closing. The shortcode worked in SilverStripe 3 when image tags were self-closing .

How can get the tags in SilverStripe to self-close?

<img src="" alt="" /> 

rather than how they are now 

<img src="" alt="">

The format provided by Silverstripe 4 is HTML5 compliant, so it is right. Self-closing everything is a legacy workaround to make XHTML1 happy.

Given that, you can modify the way images are rendered by modifying vendor/silverstripe/framework/src/View/Parsers/ShortcodeParser.php. Better yet, subclass ShortCodeParser and use your class instead, directly or by leveraging the injector.

The most correct solution in my opinion would be to create an entirely new shortcode.