Extend WordPress gallery shortcode to use tables

Hi,

We are using the default ‘gallery’ shortcode in our latest project which is something we don’t normally use but thought we would give it a go.

Our posts are also sent out in email form so when this happens we need to convert the gallery to a table. Is there any way that this can be done without completely rewriting the gallery shortcode?

Thanks!

  • Ash
    • WordPress Hacker

    Hello @chris Page

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    I don’t think it would be possible without rewriting the gallery shortcode.

    Do you use gallery shortcode as the email content? Are you using any other plugin to send the email? Please tell me some more about this.

    Cheers

    Ash

  • Chris Page
    • Flash Drive

    Hi @ashok,

    That’s what I suspected – annoying!

    The gallery shortcode would form part of the content and indeed be displayed on the email. This is why we really need it formatted as tables rather than the current dd,dt and div setup. We have created a custom plugin to interact with Campaign Monitor and send it out through them.

    Basically if you append the permalink with ?mailer it loads an alternative template which is constructed using tables.

    Thanks,

    Chris.

  • Ash
    • WordPress Hacker

    Hello @chris Page

    I have got an idea. If you go to /wp-includes/media.php line no 908 to 1101 you will see the gallery shortcode code. Use the same code and use your own layout. Fox example, the pastebin code: http://pastebin.com/8P2Jg1fs

    Then you can use [custom_gallery] shortcode and the result will be same.

    Now what you need to do is changing the layout. You have all the items in $attachments array, so add your own html and return that html.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers

    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.