Skip to content

Commit

Permalink
Merge pull request #3439 from ampproject/update/gallery-link-attribute
Browse files Browse the repository at this point in the history
Account for filtering of gallery 'link' attribute
  • Loading branch information
westonruter authored Oct 4, 2019
2 parents 75b2238 + 974c0af commit 53e18d0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions includes/embeds/class-amp-gallery-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,20 @@ public function maybe_override_gallery( $html, $attributes ) {
return $attr;
};

$set_link_attribute = static function ( $attributes ) {
$attributes['link'] = 'none';
return $attributes;
};

remove_filter( 'post_gallery', [ $this, 'maybe_override_gallery' ], 10 );
add_filter( 'wp_get_attachment_image_attributes', $add_lightbox_attribute );
add_filter( 'shortcode_atts_gallery', $set_link_attribute, PHP_INT_MAX );

$attributes['link'] = 'none';
$html = gallery_shortcode( $attributes );
$html = gallery_shortcode( $attributes );

remove_filter( 'wp_get_attachment_image_attributes', $add_lightbox_attribute );
add_filter( 'post_gallery', [ $this, 'maybe_override_gallery' ], 10, 2 );
remove_filter( 'shortcode_atts_gallery', $set_link_attribute, PHP_INT_MAX );
}

return $html;
Expand Down

0 comments on commit 53e18d0

Please sign in to comment.