cdukes / bones-for-genesis-2-0

A starting point for new Genesis projects. Built for Genesis 3.* and WordPress 5.*+.
GNU General Public License v3.0
182 stars 61 forks source link

P tags around images function #20

Closed Fortyfive closed 10 years ago

Fortyfive commented 10 years ago

Hi Cooper, your preg_replace does not seem to work:

return pregreplace( '/

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

Yet this one does for me:

return pregreplace('/

\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 commented 10 years ago

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

Fortyfive commented 10 years ago

Great, look forward to it.

cdukes commented 10 years ago

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 commented 10 years ago

Will do, thanks Cooper.