WordPress.org

Make WordPress Core

Ticket #18178: gallery-no-link.18178.diff

File gallery-no-link.18178.diff, 1.4 KB (added by helgatheviking, 9 years ago)

supports link=none, same as Chip's version, but newer

  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 682ffbb..c87bf70 100644
    function gallery_shortcode($attr) { 
    777777
    778778        $i = 0;
    779779        foreach ( $attachments as $id => $attachment ) {
    780                 $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
     780                /*
     781                * Output image link. By default, image links to
     782                * attachment page. If link="file" is passed to
     783                * the shortcode, the image links directly to
     784                * the file.
     785                */
     786                $image_link = isset( $attr['link'] ) && 'file' == $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false );
     787                /*
     788                * Output flat image. By default, image links to
     789                * attachment page. If link="none" is passed to
     790                * the shortcode, a flat (unlinked) image is
     791                * output.
     792                 */
     793                $flat_image = ( isset( $attr['link'] ) && 'none' == $attr['link'] ? wp_get_attachment_image( $id, $size, false ) : false );
     794                // Determine whether to output a linked or flat image
     795                $image_output = ( $flat_image ? $flat_image : $image_link );
    781796
    782797                $output .= "<{$itemtag} class='gallery-item'>";
    783798                $output .= "
    784799                        <{$icontag} class='gallery-icon'>
    785                                 $link
     800                                $image_output
    786801                        </{$icontag}>";
    787802                if ( $captiontag && trim($attachment->post_excerpt) ) {
    788803                        $output .= "