WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #29832


Ignore:
Timestamp:
10/02/2014 01:33:15 PM (5 years ago)
Author:
SergeyBiryukov
Comment:

Related: #14130, #20230.

I am currently trying to use a lightbox plugin on a gallery, but it needs to insert an extra attribute onto the image links.

gallery_shortcode() calls wp_get_attachment_link(), so you can use the wp_get_attachment_link filter.

I can understand why the "post_gallery" filter is called so soon, for devs who want to completely replace the functionality of this shortcode.

You can actually change the output of the shortcode using that filter without completely replacing the functionality:

function filter_gallery_shortcode_output_29832( $gallery, $attr ) {
	remove_filter( 'post_gallery', __FUNCTION__, 10, 2 );

	$gallery = gallery_shortcode( $attr );

	add_filter( 'post_gallery', __FUNCTION__, 10, 2 );

	// Change the output
	// $gallery = ...

	return $gallery;
}
add_filter( 'post_gallery', 'filter_gallery_shortcode_output_29832', 10, 2 );

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29832 – Description

    initial v1  
    1 This is similar to [#26623] but a lot simpler.
     1This is similar to #26623 but a lot simpler.
    22
    33The attached patch adds a "gallery_content" filter to the end of the gallery shortcode.