WordPress.org

Make WordPress Core

Ticket #22085: media.php.patch

File media.php.patch, 640 bytes (added by deltafactory, 8 years ago)

Pass post ID so that attachment is properly linked

  • media.php

     
    12201220}
    12211221add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
    12221222
     1223function wp_plupload_include_attachment_id( $params ) {
     1224        global $post_ID;
     1225        if ( isset( $post_ID ) )
     1226                $params['post_id'] = (int) $post_ID;
     1227
     1228        return $params;
     1229}
     1230add_filter( 'plupload_default_params', 'wp_plupload_include_attachment_id' );
     1231
    12231232/**
    12241233 * Prepares an attachment post object for JS, where it is expected
    12251234 * to be JSON-encoded and fit into an Attachment model.