Ticket #12799: 12799-2.diff
File 12799-2.diff, 3.1 KB (added by , 9 years ago) |
---|
-
src/wp-includes/media.php
1393 1393 * @type string $ids A comma-separated list of IDs of attachments to display. Default empty. 1394 1394 * @type string $include A comma-separated list of IDs of attachments to include. Default empty. 1395 1395 * @type string $exclude A comma-separated list of IDs of attachments to exclude. Default empty. 1396 * @type string $maxdisp Sets a maxiumum list of attachments to display. 1396 1397 * @type string $link What to link each image to. Default empty (links to the attachment page). 1397 1398 * Accepts 'file', 'none'. 1398 1399 * } … … 1444 1445 'size' => 'thumbnail', 1445 1446 'include' => '', 1446 1447 'exclude' => '', 1448 'maxdisp' => 0, 1447 1449 'link' => '' 1448 1450 ), $attr, 'gallery' ); 1449 1451 1450 1452 $id = intval( $atts['id'] ); 1451 1453 1454 $maxdisp = intval( $atts['maxdisp'] ); 1455 if ( $maxdisp <= 0 ) 1456 $maxdisp = -1; 1457 1452 1458 if ( ! empty( $atts['include'] ) ) { 1453 $_attachments = get_posts( array( 'include' => $atts['include'], ' post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );1459 $_attachments = get_posts( array( 'include' => $atts['include'], 'numberposts' => $maxdisp, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1454 1460 1455 1461 $attachments = array(); 1456 1462 foreach ( $_attachments as $key => $val ) { … … 1457 1463 $attachments[$val->ID] = $_attachments[$key]; 1458 1464 } 1459 1465 } elseif ( ! empty( $atts['exclude'] ) ) { 1460 $attachments = get_children( array( ' post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );1466 $attachments = get_children( array( 'numberposts' => $maxdisp, 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1461 1467 } else { 1462 $attachments = get_children( array( ' post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );1468 $attachments = get_children( array( 'numberposts' => $maxdisp, 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) ); 1463 1469 } 1464 1470 1465 1471 if ( empty( $attachments ) ) { 1466 1472 return ''; 1473 1467 1474 } 1475 1476 // Necessary because in get_posts(), when specifying include="", the numberposts parameter is ignored (it's set to match the number if items in include="") 1477 if ( $maxdisp > 0 ) 1478 $attachments = array_slice( $attachments, 0, $maxdisp, true ); 1468 1479 1469 1480 if ( is_feed() ) { 1470 1481 $output = "\n";