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

P tags around images function #20

Closed
Fortyfive opened this issue Jun 10, 2014 · 4 comments
Closed

P tags around images function #20

Fortyfive opened this issue Jun 10, 2014 · 4 comments

Comments

@Fortyfive
Copy link

Hi Cooper, your preg_replace does not seem to work:

return preg_replace( '/

\s_(<a .>)?\s(<img ._ />)\s_(</a>)?\s_</p>/iU', '\1\2\3', $content );

Yet this one does for me:

return preg_replace('/

\s_?(<a ._?><img.?></a>|<img.?>)?\s*</p>/s', '\1\2\3', $content);

Wondered if this was a bug - are you having problems with the original? Could you also offer any advice on the validity of the syntax in my suggested replacement?

Ref: http://atg2.hostfortyfive.co.uk/about

Thanks

@cdukes
Copy link
Owner

cdukes commented Jun 11, 2014

I'm able to reproduce this. I'll look at some other regex options and update in the next release.

@Fortyfive
Copy link
Author

Great, look forward to it.

@cdukes
Copy link
Owner

cdukes commented Jun 21, 2014

I've decided to remove this function for now. I'm not crazy about maintaining regexes, and I think trying to strip these tags out after the fact is the wrong approach.

I've opened a ticket, requesting a filter on wpautop()'s block elements list. If this is added, we'd be able to prevent the <img>s from ever being wrapped with <p>. Please voice your support for the change if you agree.

Thanks.

@Fortyfive
Copy link
Author

Will do, thanks Cooper.

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

2 participants