[wp-trac] [WordPress Trac] #34826: Links in images that link to attachment page are outputting with double rel attribute, wp_ajax_send_attachment_to_editor()

WordPress Trac noreply at wordpress.org
Tue Dec 1 23:35:42 UTC 2015


#34826: Links in images that link to attachment page are outputting with double rel
attribute, wp_ajax_send_attachment_to_editor()
--------------------------+-----------------------------
 Reporter:  lucymtc       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 To reproduce bug:

 - In the visual editor click on Add Media.
 - Select an image from the library and from the right column select Link
 To: Attachment Page.

 The image is sent to the editor but in the outputted code the rel
 attribute of the link looks like this:


 {{{
 rel=" rel="attachment wp-att-571835""
 }}}


 When the expected is:

 {{{
 rel="attachment wp-att-571835"
 }}}

 In  /wp-admin/includes/media.php see the function
 get_image_send_to_editor(), starting on line 124:

 {{{#!php
 <?php
 if ( ! $rel ) {
         $rel = ' rel="attachment wp-att-' . esc_attr( $id ) . '"';
 } else {
         $rel = ' rel="' . esc_attr( $rel ) . '"';
 }
 }}}

 $rel is including  rel="" attribute. The problem seems to be that from the
 function wp_ajax_send_attachment_to_editor() in the file  /wp-
 admin/includes/ajax-actions.php, line 2573, is also including rel="" in
 $rel variable.

 {{{#!php
 <?php
 if ( strpos( $url, 'attachment_id') || get_attachment_link( $id ) == $url
 ) {
         $rel = ' rel="attachment wp-att-' . $id . '"';
 }
 }}}


 This is the variable passed as a parameter when calling
 get_image_send_to_editor()

 So the solution would be to change:


 {{{
 $rel = ' rel="attachment wp-att-' . $id . '"';
 }}}

 To:


 {{{
 $rel = 'attachment wp-att-' . $id;
 }}}

 in wp_ajax_send_attachment_to_editor()

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34826>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list