Make WordPress Core

Opened 15 years ago

Closed 9 years ago

#14130 closed enhancement (wontfix)

Better gallery shortcode filter

Reported by: johnbillion's profile johnbillion Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Shortcodes Keywords:
Focuses: Cc:

Description

There's a filter inside gallery_shortcode() which allows plugins to override the default gallery template ('post_gallery'), but it's called at the beginning of the function before we've fetched our gallery images. If a plugin uses this filter, it has to perform a lot of logic to determine the post gallery images.

We should add a second filter to gallery_shortcode() after we've determined our gallery images, to make plugin authors' jobs easier.

Attachments (2)

14130.patch (546 bytes) - added by johnbillion 15 years ago.
14130.2.patch (3.5 KB) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (15)

@johnbillion
15 years ago

#1 @johnbillion
15 years ago

  • Keywords has-patch added

Patch which adds a 'post_gallery_output' filter.

Similar filter to 'post_gallery' found on line 763 of same file, but we include a second parameter with our array of attachments.

#2 @nacin
14 years ago

  • Milestone changed from Awaiting Review to Future Release

#3 @carstenbach
13 years ago

  • Cc carstenbach added

#4 @TomAuger
13 years ago

  • Cc TomAuger added

#5 @ocean90
13 years ago

Duplicate: #20230

#6 @jeremyfelt
13 years ago

  • Cc jeremy.felt@… added

#7 @desrosj
12 years ago

  • Cc desrosj@… added

#8 @johnbillion
12 years ago

  • Keywords close added

No traction on this in 3 years. Suggest wontfix. Whatever method I used to get around this at the time must have worked fine.

#9 @johnbillion
12 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

#10 @HQRaja
9 years ago

  • Resolution wontfix deleted
  • Status changed from closed to reopened

Adding this filter will open up a lot of possibilities to modify the output without having to reinvent the wheel altogether. For instance, I need to make sure the captions are linked to the attachment page, while the images themselves link to the full-sized images so that visitors can click on any image to view them in any lightbox plugin that may have been activated, while still retain the ability to go to the attachments page by clicking the linked caption, and view any further details about the image and its custom fields etc. Such a filter will allow for that and other similar possibilities without having to create a new shortcode for the purpose.

#11 @netweb
9 years ago

  • Milestone set to Awaiting Review

#12 @sebastian.pisula
9 years ago

  • Keywords close removed

I sugest use my patch. For version 4.4.0

#13 @aaroncampbell
9 years ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

The first approach seemed simple enough; add a filter after the attachments are pulled. Having said that, it only skips 29 lines of logic, 13 of which are setting up attribute defaults.

The new patch has several issues, but the big one is that it really doesn't address the original problem expressed in this ticket. Adding container and item classes that can be passed in and filtered doesn't help a plugin that needed to rewrite the logic for pulling attachments in order to short circuit the gallery logic.

@HQRaja You don't need to create a whole new shortcode, just use the existing post_gallery filter. Find that filter in wp-includes/media.php, and look at the next 20-30 lines, as you may want to incorporate them into your code.

Due to the lack of interest and the ease of the work around, I'm going to go ahead and close this again.

Note: See TracTickets for help on using tickets.