[wp-trac] [WordPress Trac] #13429: Updating Link URL on image within Admin with Gallery

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 8 01:15:53 UTC 2012


#13429: Updating Link URL on image within Admin with Gallery
-----------------------------------+-----------------------------
 Reporter:  vshoward               |       Owner:
     Type:  defect (bug)           |      Status:  new
 Priority:  normal                 |   Milestone:  Future Release
Component:  Gallery                |     Version:  2.9.2
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |
-----------------------------------+-----------------------------
Changes (by benz001):

 * cc: benz001 (added)
 * keywords:  has-patch => has-patch 2nd-opinion


Comment:

 This isn't limited to external URLs for me on any site running 3.3.1 (and
 probably earlier).
 Any URL inserted through the insert image dialog gets rewritten to link to
 the attachment page, even if you edit it in the html view.

 I don't think the place to fix this bug is in media.php, unless it's to
 stop the rel="attachment" attribute getting added in the first place, and
 I can't see an obvious way to decide when and when not to add that
 attribute.

 So the other way to attack it is via the _fix_attachment_links( ) function
 in /wp-admin/includes/post.php.

 '''Here's the clue''': If you revert this function to the one in wordpress
 2.8 release the correct behaviour returns.

 The change that triggers the error looks like it's the addition of the
 preg_replace_callback
 {{{
                  $_fix_attachment_link_id = $id;
                 $post_replace[$i] = preg_replace_callback(
 "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
 }}}

 If I follow this correctly it's completely rewriting the href attribute by
 calling into get_attachment_link() in the callback function.
 So any link with rel="attachment" and a parsable ID in that rel anywhere
 in the post content will get destroyed by this every time a post is saved.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/13429#comment:43>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list