Make WordPress Core

Ticket #12799: 12799.2.diff

File 12799.2.diff, 1.9 KB (added by viralsampat, 2 years ago)

I have checked it from my end and added my patch

  • src/wp-includes/media.php

    diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
    index 804a34f6ac..ae2cc3b7c8 100644
    a b function gallery_shortcode( $attr ) { 
    24082408         * @param string $output   The gallery output. Default empty.
    24092409         * @param array  $attr     Attributes of the gallery shortcode.
    24102410         * @param int    $instance Unique numeric ID of this gallery shortcode instance.
     2411         * @param int    $total_count Sets a maxiumum list of attachments to display.
    24112412         */
    24122413        $output = apply_filters( 'post_gallery', '', $attr, $instance );
    24132414
    function gallery_shortcode( $attr ) { 
    24262427                        'captiontag' => $html5 ? 'figcaption' : 'dd',
    24272428                        'columns'    => 3,
    24282429                        'size'       => 'thumbnail',
     2430                        'total_count' => 0,
    24292431                        'include'    => '',
    24302432                        'exclude'    => '',
    24312433                        'link'       => '',
    function gallery_shortcode( $attr ) { 
    24362438
    24372439        $id = (int) $atts['id'];
    24382440
     2441        $total_count = intval( $atts['count'] );
     2442
     2443        // Check total_count isset and less than 0
     2444        if( isset( $total_count ) && $total_count <= 0 ) {
     2445                $total_count = -1;
     2446        }
     2447       
     2448        // Check atts is not empty.
    24392449        if ( ! empty( $atts['include'] ) ) {
    24402450                $_attachments = get_posts(
    24412451                        array(
    function gallery_shortcode( $attr ) { 
    24452455                                'post_mime_type' => 'image',
    24462456                                'order'          => $atts['order'],
    24472457                                'orderby'        => $atts['orderby'],
     2458                                'numberposts'    => $total_count,
    24482459                        )
    24492460                );
    24502461
    function gallery_shortcode( $attr ) { 
    24622473                                'post_mime_type' => 'image',
    24632474                                'order'          => $atts['order'],
    24642475                                'orderby'        => $atts['orderby'],
     2476                                'numberposts'    => $total_count,
    24652477                        )
    24662478                );
    24672479        } else {
    function gallery_shortcode( $attr ) { 
    24732485                                'post_mime_type' => 'image',
    24742486                                'order'          => $atts['order'],
    24752487                                'orderby'        => $atts['orderby'],
     2488                                'numberposts'    => $total_count,
    24762489                        )
    24772490                );
    24782491        }