Support » Fixing WordPress » wpautop introduces tags in the middle of tags

  • 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"

    which is perfectly legit, will result in that:

    <img class="alignright"<br/>

    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


    Thread Starter Claude Vedovini


    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


    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

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