Make WordPress Core

Ticket #29237: 29237.2.diff

File 29237.2.diff, 2.1 KB (added by iamfriendly, 10 years ago)

Added the @since doc string to reflect when the linksize attribute was added

  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index e0ed8f4..cd1786c 100644
    add_shortcode('gallery', 'gallery_shortcode'); 
    13631363 * WordPress images on a post.
    13641364 *
    13651365 * @since 2.5.0
     1366 * @since 4.4.0 The `$linksize` attributewas added to $attr.
    13661367 *
    13671368 * @staticvar int $instance
    13681369 *
    add_shortcode('gallery', 'gallery_shortcode'); 
    13861387 *     @type string $exclude    A comma-separated list of IDs of attachments to exclude. Default empty.
    13871388 *     @type string $link       What to link each image to. Default empty (links to the attachment page).
    13881389 *                              Accepts 'file', 'none'.
     1390 *     @type string $linksize   Size of the images to link to. A string keyword (thumbnail,
     1391 *                                              medium, large, or full) as allowed by wp_get_attachment_image_src().
     1392 *                                              Default empty.
    13891393 * }
    13901394 * @return string HTML content to display gallery.
    13911395 */
    function gallery_shortcode( $attr ) { 
    14351439                'size'       => 'thumbnail',
    14361440                'include'    => '',
    14371441                'exclude'    => '',
    1438                 'link'       => ''
     1442                'link'       => '',
     1443                'linksize'      => ''
    14391444        ), $attr, 'gallery' );
    14401445
    14411446        $id = intval( $atts['id'] );
    function gallery_shortcode( $attr ) { 
    15361541
    15371542                $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
    15381543                if ( ! empty( $atts['link'] ) && 'file' === $atts['link'] ) {
    1539                         $image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr );
     1544                        if ( ! empty( $atts['linksize'] ) ) {
     1545                                $image_src = wp_get_attachment_image_src( $id, $atts['linksize'] );
     1546                                $image_output = "<a href='" . $image_src[0]. "'>" . wp_get_attachment_image( $id, $atts['size'], false ) . '</a>';
     1547                        } else {
     1548                                $image_output = wp_get_attachment_link( $id, $atts['size'], false, false );
     1549                        }
     1550                        // $image_output = wp_get_attachment_link( $id, $atts['size'], false, false, false, $attr );
    15401551                } elseif ( ! empty( $atts['link'] ) && 'none' === $atts['link'] ) {
    15411552                        $image_output = wp_get_attachment_image( $id, $atts['size'], false, $attr );
    15421553                } else {