Make WordPress Core


Ignore:
Timestamp:
03/18/2016 08:04:19 PM (8 years ago)
Author:
azaozz
Message:

Media: fix erroneously inserting a rel attribute in get_image_send_to_editor(). Reverts most of [34259] and [34260] and adds a unit test.

Props joemcgill, azaozz.
Fixes #36084.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r36472 r37035  
    25762576    }
    25772577
    2578     $rel = '';
    25792578    $url = empty( $attachment['url'] ) ? '' : $attachment['url'];
    2580     if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url ) {
    2581         $rel = 'attachment wp-att-' . $id;
    2582     }
     2579    $rel = ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url );
    25832580
    25842581    remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
     
    26012598    } else {
    26022599        $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
     2600        $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized
     2601
    26032602        if ( ! empty( $url ) ) {
    2604             $html = '<a href="' . esc_url( $url ) . '"' . 'rel="' . esc_attr( $rel ) . '">' . $html . '</a>';
     2603            $html = '<a href="' . esc_url( $url ) . '"' . $rel . '">' . $html . '</a>';
    26052604        }
    26062605    }
Note: See TracChangeset for help on using the changeset viewer.