Make WordPress Core

Ticket #12799: 12799-media-enhancement.diff

File 12799-media-enhancement.diff, 364 bytes (added by sachinrajcp123, 10 months ago)

Adds limit attribute support to the [gallery] shortcode. This patch trims the image IDs if limit is set. Props @sachinrajcp123

Line 
1diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
2index abc1234..xyz5678 100644
3--- a/src/wp-includes/media.php
4+++ b/src/wp-includes/media.php
5@@ function gallery_shortcode
6+   // Add limit attribute support
7+   $limit = isset($attr['limit']) ? intval($attr['limit']) : 0;
8+   if ($limit > 0) {
9+       $ids = array_slice($ids, 0, $limit);
10+   }