Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-wrapping images with <figure> tag buggy #248

Open
nickbouton opened this issue Dec 12, 2013 · 1 comment
Open

Auto-wrapping images with <figure> tag buggy #248

nickbouton opened this issue Dec 12, 2013 · 1 comment

Comments

@nickbouton
Copy link

Seems to be present in both Reverie 4 & 5 as the reverie_img_unautop() function in clean.php has not changed.

Probably an issue with the regex being too greedy, but if you place an image inside a regular content paragraph with alignleft, alignright, or aligncenter, the resulting <figure> tag expands around the next paragraph (or more) of text as well, not just the image, and doesn't close properly until the end of the entry content.

Stopgap fix is to remove the reverie_img_unautop() function altogether.

@nickbouton
Copy link
Author

Updating the body of reverie_img_unautop() to look for XHTML-valid <img /> tags seems to do the trick of handling images wrapped in <p></p> tags but not catching regular images aligned inside of content blocks (which don't need the preprocessing), FWIW.

Probably not perfect as HTML5 allows non-self-closing tags, but works for me as a temporary replacement:

function reverie_img_unautop($pee) {
    return preg_replace('/<p>\\s*?(<a .*?><img.*?\/><\\/a>|<img.*?\/>)?\\s*<\\/p>/s',
        '<figure class="figure">$1</figure>', $pee);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant