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

WordPress Trac noreply at wordpress.org
Fri Jun 26 18:58:30 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:  4.3
Component:  Media           |     Version:  trunk
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+--------------------
Changes (by pareshradadiya):

 * keywords:  has-patch reporter-feedback => has-patch


Comment:

 The issue is only appears in the MU sites. This snippets is for creating a
 clone of an attachments

 {{{
 #!python
 /**
  * Create a copy of the attachment.
  */
 function test_clone_attachment() {

         /** Get an old attachment post by id **/
         $attachment1 = get_post( '4' );

         $args = array(
                 'post_mime_type' => $attachment1->post_mime_type,
                 'guid'           => $attachment1->guid,
                 'post_title'     => $attachment1->post_title,
                 'post_content'   => $attachment1->post_content,
                 'post_parent'    => 0,
         );

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

         echo( wp_get_attachment_url( $attachment2 ) );

 }

 add_action( 'init', 'test_clone_attachment' );

   }}}

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


More information about the wp-trac mailing list