• I didn’t tested with other tags but it seems that wpautop is introducing <br> tags inside other <img> tags if they contain line breaks between attributes.

    For example, this:

    <img class="alignright"
    src="https://mydomain.com/myimage">

    which is perfectly legit, will result in that:

    <img class="alignright"<br/>
    src="https://mydomain.com/myimage">

    which is obviously invalid.

Viewing 4 replies - 1 through 4 (of 4 total)
  • * @param bool   $br  Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true.
    
    function wpautop($pee, $br = true) {
     ...
    }

    looks like just make $br false and that should allow you to do your multiline tags

    via https://core.trac.www.ads-software.com/browser/tags/4.2.2/src/wp-includes/formatting.php#L0

    Thread Starter Claude Vedovini

    (@cvedovini)

    yes, but in that case I am not the one calling wpautop so I don’t have control over the arguments.

    moreover I don’t see why it would cut the <img> tags like that, from the code it seems like it tries to preserve other tags so why not this one?

    Thread Starter Claude Vedovini

    (@cvedovini)

    To describe how I come about that problem, which is new to me:

    One of my plugin is introducing an <img> tag in the content, either through a shortcode or a filter.

    It just happen that for formatting reason the <img> is output with line breaks between attributes, which is perfectly valid HTML

    Recently users have been reporting that the output is messed up with because those <br/> tags are introduced inside the <img> tag.

    I tested it on a bland WordPress with Twentythirteen and it’s definitely a new thing. You can also type that in the editor and it will mess it up.

    if it’s out of your hands, contact the author of the multi-line <img> within wpautop(x,false) and let them know of this issue.

    as for preservation of img tag vs others, you can open a bug ticket https://core.trac.www.ads-software.com/newticket

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wpautop introduces tags in the middle of tags’ is closed to new replies.