[wp-trac] [WordPress Trac] #32145: wp_get_attachment_url() append /sites/$blog_id/ twice in url

WordPress Trac noreply at wordpress.org
Sat Jul 4 06:25:14 UTC 2015


#32145: wp_get_attachment_url() append /sites/$blog_id/ twice in url
-----------------------------+------------------------------
 Reporter:  pareshradadiya   |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Media            |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |     Focuses:  multisite
-----------------------------+------------------------------
Changes (by jeremyfelt):

 * keywords:  has-patch => has-patch close
 * focuses:   => multisite
 * milestone:  4.3 => Awaiting Review


Comment:

 `wp_insert_attachment()` expects a file location on the server rather than
 a URL. Using `get_attached_file()` instead to grab the file location as
 it's stored in post meta will create the proper attachment URL.

 `$attachment2 = wp_insert_attachment( $args, get_attached_file(
 $attachment1->ID ), '0' );`

 I can't speak for how solid things are after that when juggling a file
 attached to multiple posts, but it appears the code above will work with
 this change.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32145#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list