Open benlk opened 5 years ago
If we want to fix this parser:
If we don't want to fix the parser:
largo_hero
via that functionPersonally, I'm in favor of the deprecation technique.
By removing Largo Featured Media in favor of Gutenberg, sites will have more editorial control over how the media displays in their posts, with the same level of control over whether it displays at all. Getting rid of the featured media output would also bring Largo's existing templates closer to the "Blank Slate" template described in https://github.com/INN/largo/issues/1663
https://github.com/INN/largo/blob/512da701664b329f2f92244bbe54880a6e146431/inc/post-templates.php#L191-L204
In situations where the first block on a post is an image block, the first paragraph of the post is not the image tag. It's a comment.
as a post content will be passed through the filter.
$p[0]
is'<!-- wp:image {"id":4923609,"className":"size-large wp-image-4923609"} -->'
, not an image that matches the regex.Even if we adjusted this algorithm to skip the opening comment, and to treat figcaptions like the paragraph tag, we're edging into the dangerous territory for parsing HTML with regular expressions. https://stackoverflow.com/a/1732454