[wp-trac] [WordPress Trac] #41853: Filter to handle/override the list of IDs in the Gallery Shortcode

WordPress Trac noreply at wordpress.org
Mon Sep 11 07:55:25 UTC 2017


#41853: Filter to handle/override the list of IDs in the Gallery Shortcode
-----------------------------+-----------------------------
 Reporter:  TigrouMeow       |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Gallery          |    Version:  4.8.1
 Severity:  normal           |   Keywords:
  Focuses:  ui               |
-----------------------------+-----------------------------
 It would be nice to handle the IDs of the media which are used in the
 Gallery Shortcode from other plugins, depending on the attributes of the
 shortcode for instance.

 A simple filter like:

 {{{#!php
 $attr['ids'] = apply_filters( 'gallery_images', !empty( $attr['ids'] ) ?
 $attr['ids'] : null, $attr );
 }}}

 Would be perfect! And it could be right before:

 {{{#!php
 if ( ! empty( $attr['ids'] ) ) {
   // 'ids' is explicitly ordered, unless you specify otherwise.
   if ( empty( $attr['orderby'] ) ) {
                 $attr['orderby'] = 'post__in';
   }
   $attr['include'] = $attr['ids'];
 }
 }}}

 It is a simple change that wouldn't break anything. And it would allow
 plugins/themes to handle images in Gallery without having to create
 complicated Gallery systems. What about it?

 Thanks :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41853>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list