/** * Handle an uploaded thumbnail image and associate it with a specific video * * @global BC_Accounts $bc_accounts * * @param string $account_hash * @param int $video_id * @param string $url * @param int $width * @param int $height */ public function ajax_thumb_upload($account_hash, $video_id, $url, $width, $height) { global $bc_accounts; // Set up the account to which we're pushing data $account = $bc_accounts->set_current_account($account_hash); if (false === $account) { // Account was invalid, fail // Restore our global, default account $bc_accounts->restore_default_account(); return; } // Sanitize our passed data $video_id = BC_Utility::sanitize_id($video_id); $url = esc_url($url); if (empty($url)) { // Attachment has no URL, fail $bc_accounts->restore_default_account(); return; } $height = absint($height); $width = absint($width); // Push the thumbnail to Brightcove $this->cms_api->thumbnail_upload($video_id, $url, $height, $width); // Restore our global, default account $bc_accounts->restore_default_account(); }