WordPress.org

Ready to get started?Download WordPress

Forums

EG-Attachments
[resolved] Plugin shows header and footer when no attachments are shown (5 posts)

  1. Mike
    Member
    Posted 3 years ago #

    Hello,

    I noticed this behaviour upon using EG-Attachments a couple times.

    If for example, you set doctype=document but the post has only images attached to it, you will get a blank list of attachments showing up (ie the plugin creates content on the page, but is not actually showing anything other than its header and footer). This is a bit of an issue if you use a custom type to add a header to your list of attachments, then the header will show but no attachments.

    I created a simple diff patch that corrects the problem by counting the number of attachments that are actually being printed out (instead of just counting to ensure that the array length of attachments is > 0 (as the array contains all attachment types). If this number is set to 0 after the shortcode finishes looping through the attachments array, then it returns ''.

    You can find the diff here: http://michaelblouin.info/filebin/eg-attachments-no-attachments.patch

    Hope this helps and thank you for a great plugin!
    Michael Blouin

    http://wordpress.org/extend/plugins/eg-attachments/

  2. Mike
    Member
    Posted 3 years ago #

    Actually... Come to think of it, not sure why I posted this here.. Anyways, creating a post in trac...

  3. Mike
    Member
    Posted 3 years ago #

    Hmm... Nevermind.. This plugin isn't in Trac...

  4. Mike
    Member
    Posted 3 years ago #

    I made one more update to the diff patch. I changed it so that when it checks if $attachment_count == 0 it also checks if $output == '', and if either is true it returns ''.

    I then removed several if statements that were checking if $output == '' to optimize the code a little.

    This diff is available here: eg-attachments-no-attachments-optimize.patch

    Mike

  5. EmmanuelG
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for the suggestion.
    The version 1.8 is now published, and takes your comment into account.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic