Look at the HTML generated by this markdown. In both cases the image (or whatever the image render hook produces) is wrapped within a p
element. That is how markdown is rendered to HTML per the CommonMark specification.
So if your image render hook produces a figure
element, it will be wrapped within a p
element, which is invalid HTML.
If you run the rendered page through an HTML validator, it will fail.
This is not true. Use the embedded figure shortcode, or create your own, or simulate a figure
element using span
elements. More info in this topic.