WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#25405 closed defect (bug) (duplicate)

The 'link' attribute not passed through shortcode_atts in the gallery shortcode callback

Reported by: birgire Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6.1
Component: Shortcodes Keywords: has-patch
Focuses: Cc:

Description

I was trying out the great new shortcode_atts_gallery filter on the 'link' attribute to let [gallery] behave like [gallery link="file"] by default.

Here is what I had in mind:

    add_filter( 'shortcode_atts_gallery', 'my_gallery_atts', 10, 3 );
    function my_gallery_atts( $out, $pairs, $atts ) {
        if ( ! isset( $atts['link'] ) )
    	    $out['link'] = 'file';
        
        return $out;
    }

but this didn't work to my surprise. I checked the source and the reason seems to be that the 'link' attribute is not passed through shortcode_atts for some reason, as you can see here:

        extract(shortcode_atts(array(
                'order'      => 'ASC',
                'orderby'    => 'menu_order ID',
                'id'         => $post ? $post->ID : 0,
                'itemtag'    => 'dl',
                'icontag'    => 'dt',
                'captiontag' => 'dd',
                'columns'    => 3,
                'size'       => 'thumbnail',
                'include'    => '',
                'exclude'    => ''
        ), $attr, 'gallery'));

So I'm not sure why the default 'link' = '' parameter is not listed there too.

Attachments (1)

media.diff.txt (920 bytes) - added by birgire 7 years ago.

Download all attachments as: .zip

Change History (2)

@birgire
7 years ago

#1 @ocean90
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #24979.

Note: See TracTickets for help on using tickets.