Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

img_unautop is greedy #95

Closed
swinggraphics opened this issue Aug 20, 2014 · 5 comments
Closed

img_unautop is greedy #95

swinggraphics opened this issue Aug 20, 2014 · 5 comments
Labels

Comments

@swinggraphics
Copy link

Had to comment out the img_unautop function in cleanup.php because it adds figure tags inappropriately, replacing a <p> tag with <figure> that is nowhere near an img, then closing it somewhere far down the page. My brain is too foggy to troubleshoot the regex right now, but I'll post again if I figure it out.

@Aetles
Copy link
Contributor

Aetles commented Aug 20, 2014

Yeah, img_unautop() caused problem for me as well, I remove it whenever using FoundationPress.

By the way, I think img_unautop() is copied from this article but I don't see any credit for it in the code.

@olefredrik
Copy link
Owner

@swinggraphics Hm. Interesting. Thanks for reporting the error. Let me know if you figure out a solution.
@Aetles You're right. My bad. 30c3a6a

@olefredrik olefredrik added the bug label Oct 22, 2014
@stirlingsohn
Copy link

we also had to take it out because it removes all css classes from images inside the_content().

@DavidBruchmann
Copy link

The best is to keep the wrap in that function out, then the function is really only doing what the name says and it keeps it simple.

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

Additionally I'd remove the regex-part perhaps for removing the p around linked images as links are inline-elements that should be wrapped usually.

function img_unautop($pee) {
    $pee = preg_replace('/<p>\\s*?(<img.*?>)?\\s*<\\/p>/s', '$1', $pee);
    return $pee;
}

@olefredrik
Copy link
Owner

The img_unautop function was removed in bcd2505#diff-1565ad18be73929a637f7cc08011590cL198

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

No branches or pull requests

5 participants