Make WordPress Core

Ticket #22101: 22101.3.patch

File 22101.3.patch, 1.8 KB (added by birgire, 7 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index dbc9c7d..e80baab 100644
    function gallery_shortcode( $attr ) { 
    16991699        if ( is_feed() ) {
    17001700                $output = "\n";
    17011701                foreach ( $attachments as $att_id => $attachment ) {
    1702                         $output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n";
     1702                        if ( ! empty( $atts['link'] ) ) {
     1703                                if( 'none' === $atts['link'] ) {
     1704                                        $output .= wp_get_attachment_image( $att_id, $atts['size'], false, $attr );
     1705                                } else {
     1706                                        $output .= wp_get_attachment_link( $att_id, $atts['size'], false );
     1707                                }
     1708                        } else {
     1709                                $output .= wp_get_attachment_link( $att_id, $atts['size'], true );
     1710                        }
     1711                        $output .= "\n";
    17031712                }
    17041713                return $output;
    17051714        }
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 392c039..9dc6a49 100644
    EOF; 
    20622062                $attachment_id = wp_insert_attachment( $data, '', 0 );
    20632063                $this->assertSame( 0, $attachment_id );
    20642064        }
     2065
     2066        /**
     2067         * @ticket 22101
     2068         */
     2069        function test_gallery_shortcode_when_is_feed_true() {
     2070
     2071                $this->go_to( '/?feed=rss2' );
     2072
     2073                // Default: Links to image attachment page url
     2074                $actual = gallery_shortcode( array(
     2075                        'ids'      => self::$large_id,
     2076                ) );
     2077                $this->assertContains( '?attachment_id=', $actual );
     2078
     2079                // File: Links to image file url
     2080                $actual = gallery_shortcode( array(
     2081                        'ids'   => self::$large_id,
     2082                        'link'  => 'file',
     2083                ) );
     2084                $this->assertTrue( 2 == substr_count( $actual, '.png' ) );
     2085
     2086                // None: Does not link
     2087                $actual = gallery_shortcode( array(
     2088                        'ids'   => self::$large_id,
     2089                        'link'  => 'none',
     2090                ) );
     2091                $this->assertFalse( strpos( $actual, '<a ' ) );
     2092        }
     2093
    20652094}
    20662095
    20672096/**