WordPress.org

Make WordPress Core

Ticket #5911: 5911-rel.diff

File 5911-rel.diff, 2.6 KB (added by andy, 7 years ago)

add rel attrs to attachment links inserted from uploader

  • wp-admin/includes/media.php

     
    5050 
    5151function get_image_send_to_editor($id, $alt, $title, $align, $url='', $rel = false, $size='medium') { 
    5252 
    53         $html = get_image_tag($id, $alt, $title, $align, $rel, $size); 
     53        $html = get_image_tag($id, $alt, $title, $align, $size); 
    5454 
    5555        $rel = $rel ? ' rel="attachment wp-att-'.attribute_escape($id).'"' : ''; 
    5656 
     
    246246                $send_id = (int) array_shift($keys); 
    247247                $attachment = $_POST['attachments'][$send_id]; 
    248248                $html = $attachment['post_title']; 
    249                 if ( !empty($attachment['url']) ) 
    250                         $html = "<a href='{$attachment['url']}'>$html</a>"; 
     249                if ( !empty($attachment['url']) ) { 
     250                        if ( strpos($attachment['url'], 'attachment_id') || false !== strpos($attachment['url'], get_permalink($_POST['post_id'])) ) 
     251                                $rel = " rel='attachment wp-att-".attribute_escape($send_id)."'"; 
     252                        $html = "<a href='{$attachment['url']}'$rel>$html</a>"; 
     253                } 
    251254                $html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); 
    252255                return media_send_to_editor($html); 
    253256        } 
     
    527530                else 
    528531                        $size = 'medium'; 
    529532 
    530                 return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size); 
     533                return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, true, $size); 
    531534        } 
    532535 
    533536        return $html; 
  • wp-includes/media.php

     
    9191} 
    9292 
    9393// return an <img src /> tag for the given image attachment, scaling it down if requested 
    94 function get_image_tag($id, $alt, $title, $align, $rel = false, $size='medium') { 
     94function get_image_tag($id, $alt, $title, $align, $size='medium') { 
    9595 
    9696        list( $img_src, $width, $height ) = image_downsize($id, $size); 
    9797        $hwstring = image_hwstring($width, $height); 
    9898 
    99         $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align'.attribute_escape($align).' size-'.attribute_escape($size).' attachment wp-att-'.attribute_escape($id).'" />'; 
     99        $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'" '.$hwstring.'class="align'.attribute_escape($align).' size-'.attribute_escape($size).' wp-image-'.$id.'" />'; 
    100100 
    101101        $html = apply_filters( 'image_send_to_editor', $html, $id, $alt, $title, $align, $url ); 
    102102