WordPress.org

Make WordPress Core

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

File gallery-no-link.18178a.diff, 2.5 KB (added by helgatheviking, 4 months ago)

Add "none" option to dropdown on gallery pop-up window

  • wp-admin/includes/media.php

    diff --git wp-admin/includes/media.php wp-admin/includes/media.php
    index 5e9912b..f45ac61 100644
    function media_upload_form_handler() { 
    445445 
    446446        if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { 
    447447                $attachment = wp_unslash( $attachment ); 
    448          
     448 
    449449                $post = $_post = get_post($attachment_id, ARRAY_A); 
    450450                $post_type_object = get_post_type_object( $post[ 'post_type' ] ); 
    451451 
  • wp-includes/media-template.php

    diff --git wp-includes/media-template.php wp-includes/media-template.php
    index 7e79efd..61f1ee3 100644
    function wp_print_media_templates() { 
    353353                                <option value="post"> 
    354354                                        <?php esc_attr_e('Attachment Page'); ?> 
    355355                                </option> 
     356                                <option value="none"> 
     357                                        <?php esc_attr_e('None'); ?> 
     358                                </option> 
    356359                        </select> 
    357360                </label> 
    358361 
  • wp-includes/media.php

    diff --git wp-includes/media.php wp-includes/media.php
    index 2b770ce..db07c95 100644
    function gallery_shortcode($attr) { 
    763763                                text-align: center; 
    764764                                width: {$itemwidth}%; 
    765765                        } 
    766                         #{$selector} img { 
    767                                 border: 2px solid #cfcfcf; 
    768                         } 
    769766                        #{$selector} .gallery-caption { 
    770767                                margin-left: 0; 
    771768                        } 
    function gallery_shortcode($attr) { 
    777774 
    778775        $i = 0; 
    779776        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); 
     777                /* 
     778                * Output image link. By default, image links to 
     779                * attachment page. If link="file" is passed to 
     780                * the shortcode, the image links directly to 
     781                * the file. 
     782                */ 
     783                $image_link = isset( $attr['link'] ) && 'file' == $attr['link'] ? wp_get_attachment_link( $id, $size, false, false ) : wp_get_attachment_link( $id, $size, true, false ); 
     784                /* 
     785                * Output flat image. By default, image links to 
     786                * attachment page. If link="none" is passed to 
     787                * the shortcode, a flat (unlinked) image is 
     788                * output. 
     789                 */ 
     790                $flat_image = ( isset( $attr['link'] ) && 'none' == $attr['link'] ? wp_get_attachment_image( $id, $size, false ) : false ); 
     791                // Determine whether to output a linked or flat image 
     792                $image_output = ( $flat_image ? $flat_image : $image_link ); 
    781793 
    782794                $output .= "<{$itemtag} class='gallery-item'>"; 
    783795                $output .= " 
    784796                        <{$icontag} class='gallery-icon'> 
    785                                 $link 
     797                                $image_output 
    786798                        </{$icontag}>"; 
    787799                if ( $captiontag && trim($attachment->post_excerpt) ) { 
    788800                        $output .= "