• Hello,

    I’m using nextgen gallery on a new theme that has a bit more of a specific layout requirement for their gallery and have run into a bit of an annoying bug / issue.

    In the ‘gallery.php’ output for a page, wordpress is adding a bunch of br and p tags throughout the output of gallery.php’s template.

    I tried removing the wpautop filters in the theme’s functions file, like so:

    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );

    but the gallery output remains the same.

    Basically I’m getting this in the output of gallery.php:

    <div class="ngg-galleryoverview" id="ngg-gallery-2-222">
    <div id="ngg-image-6" class="ngg-gallery-thumbnail-box">
    <div class="ngg-gallery-thumbnail">
    <a href="/path/to/my/gallery/name/1.jpg" title=" " rel="lightbox[set_2]"><br />
    <img title="image title" alt="image title" src="/path/to/my/image/thumbs/thumbs_1.jpg" height="74" width="115"></a><br />
    </div>
    <p></p></div>

    and so on for each thumbnail.

    Basically after the link ‘a’ tag and after the ‘img’ tag, I’m getting unwanted / unnecessary BR tags, and then a separate ‘p’ tag at the end.

    Is there any way to remove / prevent wordpress from modifying the output of the gallery and stop doing this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m having the same problem the database is clean on these tags it’s only when there drawn for the output request’s that they get added

    Any updates on this? I’ve tried ‘wpautop’, I’ve tried putting all the code for images on one line (where applicable), I’ve tried shutting off the visual editor / typing all the text & shortcode by hand / etc… Nothing. The only solution I’ve got is to rip out the ‘br’ with jQuery (even str_replace() doesn’t work!), which is just way too hacky for my tastes.

    Losin it…

    Just wanted to add an update, as the past half hour has revealed a wealth of useful information (‘the power of posting’, as they say):

    My issue was specifically with use of ‘figcaption’ within ‘figure’ in a custom NextGEN gallery template. I found this nice post from the always-clever Nicolas Gallagher: https://nicolasgallagher.com/using-html5-elements-in-wordpress-post-content/

    Though it will likely be useful in the future (or at least until WP catches up), it didn’t actually solve my problem since—as he points out in the article—it doesn’t really work with figure/figcaption.

    Then I remembered: LINE-HEIGHT! I simply set the ‘figure’ line-height to ‘0’ in the CSS, and it removes the effect of the ‘br’! It’s still a little hacky, and the tags still appear in the markup, but it’s the most minimal solution I could come up with. Certainly better than adding more JS to my page…

    Hope this helps someone.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘wordpress adding br & p tags to gallery output’ is closed to new replies.