summaryrefslogtreecommitdiff
blob: a2747f95b9e701da5992747db97eead4ddf62a15 (plain)
1
2
3
/* Do not modify this file directly. It is compiled from other files. */
/* globals wp, lodash */
wp.apiFetch.use(function(e,t){var a=e.path,i=e.method,o=e.body,n=o?o.get("file"):null;if(!a||-1===a.indexOf("/wp/v2/media"))return t(e);if(!i||"post"!==i.toLowerCase())return t(e);if(!n||0!==n.type.indexOf("video/"))return t(e);wp.media.ajax("videopress-get-upload-token",{async:!1,data:{filename:n.name}}).done(function(t){var a=e.headers||{};a.Authorization='X_UPLOAD_TOKEN token="'+t.upload_token+'" blog_id="'+t.upload_blog_id+'"',e.headers=a,delete e.path,e.url=t.upload_action_url,e.credentials="omit",o.set("media[]",n),o.delete("file"),e.body=o});var d=t(e);return new Promise(function(e,t){d.then(function(t){var a=lodash.get(t,"media[0]"),i=lodash.get(a,"ID"),o=wp.apiFetch({path:"/wp/v2/media/"+i});e(o)}).catch(function(){t()})})});