File Editor
Directories:
.. (Back)
Files:
editor-view.min.asset.php
editor-view.min.js
gutenberg-video-upload.min.asset.php
gutenberg-video-upload.min.js
media-video-widget-extensions.min.asset.php
media-video-widget-extensions.min.js
videopress-add-resumable-upload-support.min.asset.php
videopress-add-resumable-upload-support.min.js
videopress-plupload.min.asset.php
videopress-plupload.min.js
videopress-uploader.min.asset.php
videopress-uploader.min.js
Create New File
Create
Edit File: gutenberg-video-upload.min.js
window.videoPressUploadPoster=function(e,t){return new Promise((function(o,n){wp.media.ajax("videopress-get-upload-token",{async:!0}).done((function(a){var i={},r={},d=new FormData;i.Authorization='X_UPLOAD_TOKEN token="'+a.upload_token+'" blog_id="'+a.upload_blog_id+'"',r.headers=i,r.method="POST",r.url="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/poster",r.credentials="omit",Object.keys(t).forEach((e=>{d.append(e,t[e])})),r.body=d,wp.apiFetch(r).then((function(e){o(e)})).catch((function(e){n(e)}))}))}))},window.videoPressGetPoster=function(e){const t=(t,o,n=null)=>{let a="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/poster";n&&n.length&&(a+="?metadata_token="+n),wp.apiFetch({url:a,method:"GET",credentials:"omit"}).then((function(e){t(e)})).catch((function(e){o(e)}))};return new Promise((function(o,n){wp.ajax.post("videopress-get-playback-jwt",{async:!0,guid:e}).done((function(e){t(o,n,e.jwt)})).fail((()=>{t(o,n)}))}))},window.videoPressUploadTrack=function(e,t,o,n,a){return new Promise((function(i,r){wp.media.ajax("videopress-get-upload-token",{async:!0,data:{filename:a.name}}).done((function(d){var s={},p={},c=new FormData;s.Authorization='X_UPLOAD_TOKEN token="'+d.upload_token+'" blog_id="'+d.upload_blog_id+'"',p.headers=s,p.method="POST",p.url="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/tracks",p.credentials="omit",c.append("kind",t),c.append("srclang",o),c.append("label",n),c.append("vtt",a),p.body=c,wp.apiFetch(p).then((function(e){i(e)})).catch((function(e){r(e)}))}))}))},window.videoPressDeleteTrack=function(e,t,o){return new Promise((function(n,a){wp.media.ajax("videopress-get-upload-token",{async:!0}).done((function(i){var r={},d={},s=new FormData;r.Authorization='X_UPLOAD_TOKEN token="'+i.upload_token+'" blog_id="'+i.upload_blog_id+'"',d.headers=r,d.method="POST",d.url="https://public-api.wordpress.com/rest/v1.1/videos/"+e+"/tracks/delete",d.credentials="omit",s.append("kind",t),s.append("srclang",o),d.body=s,wp.apiFetch(d).then((function(e){n(e)})).catch((function(e){a(e)}))}))}))},wp.apiFetch.use((function(e,t){var o=e.path,n=e.method,a=e.body;if(!o||-1===o.indexOf("/wp/v2/media"))return t(e);if(!n||"post"!==n.toLowerCase())return t(e);var i=a?a.get("file"):null;if(!i||0!==i.type.indexOf("video/"))return t(e);wp.media.ajax("videopress-get-upload-token",{async:!1,data:{filename:i.name}}).done((function(t){var o=e.headers||{};o.Authorization='X_UPLOAD_TOKEN token="'+t.upload_token+'" blog_id="'+t.upload_blog_id+'"',e.headers=o,delete e.path,e.url=t.upload_action_url,e.credentials="omit",a.set("media[]",i),a.delete("file"),e.body=a}));var r=t(e);return new Promise((function(e,t){r.then((function(e){return e instanceof Response&&e.ok?e.json():e})).then((function(t){var o=lodash.get(t,"media[0]"),n=lodash.get(o,"ID"),a=wp.apiFetch({path:"/wp/v2/media/"+n});e(a)})).catch((function(e){"errors"in e&&"object"==typeof e.errors&&e.errors.length>0&&(e=e.errors.shift()),t(e)}))}))}));
Save Changes
Rename File
Rename