WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#17214 closed enhancement (duplicate)

Modification to Gallery

Reported by: dhmorris88 Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.1
Component: Media Keywords:
Focuses: Cc:

Description

I recently came across this in a project and was astonished that this simple feature was not included: the ability to make modifications to the native gallery shortcode functionality. Maybe I am just completed out of line, but I think it should be easy for a developer to make simple changes to the default gallery that comes with wordpress. One of the features I needed was the ability to make random gallery from the attachments and limit them to a certain number. Yes there is a order=rand feature, but no limit -- very frustrating.

I added a couple of lines to the media script in includes, knowing that as soon as WP updates its gonna wipe out what I did. So better yet this code should be included in the next update.

Here is what I added to media.php:

785 'include'    => '',
786 'exclude'    => '',
787 'limit'      => ''
796 $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby,  'numberposts' => $limit) );
804 $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'numberposts' => $limit) );
806 $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby, 'numberposts' => $limit) );

Change History (1)

comment:1 @nacin4 years ago

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

You can completely override output by using the post_gallery filter.

Otherwise this ticket is a duplicate of #11725, #7958.

Note: See TracTickets for help on using tickets.