Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
/* eslint consistent-this: [ "error", "control" ] */
|
|
|
|
(function( component ) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var VideoWidgetModel, VideoWidgetControl, VideoDetailsMediaFrame;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Custom video details frame that removes the replace-video state.
|
|
|
|
*
|
2017-12-15 08:42:46 -05:00
|
|
|
* @class wp.mediaWidgets.controlConstructors~VideoDetailsMediaFrame
|
|
|
|
* @augments wp.media.view.MediaFrame.VideoDetails
|
|
|
|
*
|
|
|
|
* @private
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
*/
|
2017-12-15 08:42:46 -05:00
|
|
|
VideoDetailsMediaFrame = wp.media.view.MediaFrame.VideoDetails.extend(/** @lends wp.mediaWidgets.controlConstructors~VideoDetailsMediaFrame.prototype */{
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create the default states.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
createStates: function createStates() {
|
|
|
|
this.states.add([
|
|
|
|
new wp.media.controller.VideoDetails({
|
|
|
|
media: this.media
|
|
|
|
}),
|
|
|
|
|
2017-05-22 18:05:42 -04:00
|
|
|
new wp.media.controller.MediaLibrary({
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
type: 'video',
|
|
|
|
id: 'add-video-source',
|
|
|
|
title: wp.media.view.l10n.videoAddSourceTitle,
|
|
|
|
toolbar: 'add-video-source',
|
|
|
|
media: this.media,
|
|
|
|
menu: false
|
2017-05-22 18:05:42 -04:00
|
|
|
}),
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
|
2017-05-22 18:05:42 -04:00
|
|
|
new wp.media.controller.MediaLibrary({
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
type: 'text',
|
|
|
|
id: 'add-track',
|
|
|
|
title: wp.media.view.l10n.videoAddTrackTitle,
|
|
|
|
toolbar: 'add-track',
|
|
|
|
media: this.media,
|
|
|
|
menu: 'video-details'
|
2017-05-22 18:05:42 -04:00
|
|
|
})
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Video widget model.
|
|
|
|
*
|
|
|
|
* See WP_Widget_Video::enqueue_admin_scripts() for amending prototype from PHP exports.
|
|
|
|
*
|
2017-12-15 08:42:46 -05:00
|
|
|
* @class wp.mediaWidgets.modelConstructors.media_video
|
|
|
|
* @augments wp.mediaWidgets.MediaWidgetModel
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
*/
|
2017-05-22 18:05:42 -04:00
|
|
|
VideoWidgetModel = component.MediaWidgetModel.extend({});
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Video widget control.
|
|
|
|
*
|
|
|
|
* See WP_Widget_Video::enqueue_admin_scripts() for amending prototype from PHP exports.
|
|
|
|
*
|
2017-12-15 08:42:46 -05:00
|
|
|
* @class wp.mediaWidgets.controlConstructors.media_video
|
|
|
|
* @augments wp.mediaWidgets.MediaWidgetControl
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
*/
|
2017-12-15 08:42:46 -05:00
|
|
|
VideoWidgetControl = component.MediaWidgetControl.extend(/** @lends wp.mediaWidgets.controlConstructors.media_video.prototype */{
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Show display settings.
|
|
|
|
*
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
showDisplaySettings: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache of oembed responses.
|
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
|
|
|
oembedResponses: {},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Map model props to media frame props.
|
|
|
|
*
|
|
|
|
* @param {Object} modelProps - Model props.
|
|
|
|
* @returns {Object} Media frame props.
|
|
|
|
*/
|
|
|
|
mapModelToMediaFrameProps: function mapModelToMediaFrameProps( modelProps ) {
|
|
|
|
var control = this, mediaFrameProps;
|
|
|
|
mediaFrameProps = component.MediaWidgetControl.prototype.mapModelToMediaFrameProps.call( control, modelProps );
|
|
|
|
mediaFrameProps.link = 'embed';
|
|
|
|
return mediaFrameProps;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetches embed data for external videos.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
fetchEmbed: function fetchEmbed() {
|
|
|
|
var control = this, url;
|
|
|
|
url = control.model.get( 'url' );
|
|
|
|
|
|
|
|
// If we already have a local cache of the embed response, return.
|
|
|
|
if ( control.oembedResponses[ url ] ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is an in-flight embed request, abort it.
|
|
|
|
if ( control.fetchEmbedDfd && 'pending' === control.fetchEmbedDfd.state() ) {
|
|
|
|
control.fetchEmbedDfd.abort();
|
|
|
|
}
|
|
|
|
|
2017-08-02 12:45:44 -04:00
|
|
|
control.fetchEmbedDfd = wp.apiRequest({
|
2017-05-11 17:24:42 -04:00
|
|
|
url: wp.media.view.settings.oEmbedProxyUrl,
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
data: {
|
|
|
|
url: control.model.get( 'url' ),
|
|
|
|
maxwidth: control.model.get( 'width' ),
|
2017-05-11 17:24:42 -04:00
|
|
|
maxheight: control.model.get( 'height' ),
|
|
|
|
discover: false
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
},
|
|
|
|
type: 'GET',
|
2017-05-11 17:24:42 -04:00
|
|
|
dataType: 'json',
|
|
|
|
context: control
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
control.fetchEmbedDfd.done( function( response ) {
|
|
|
|
control.oembedResponses[ url ] = response;
|
|
|
|
control.renderPreview();
|
|
|
|
});
|
|
|
|
|
|
|
|
control.fetchEmbedDfd.fail( function() {
|
|
|
|
control.oembedResponses[ url ] = null;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-05-20 00:18:41 -04:00
|
|
|
/**
|
|
|
|
* Whether a url is a supported external host.
|
|
|
|
*
|
2017-10-04 20:22:47 -04:00
|
|
|
* @deprecated since 4.9.
|
|
|
|
*
|
2017-05-20 00:18:41 -04:00
|
|
|
* @returns {boolean} Whether url is a supported video host.
|
|
|
|
*/
|
2017-10-04 20:58:48 -04:00
|
|
|
isHostedVideo: function isHostedVideo() {
|
2017-10-18 20:07:54 -04:00
|
|
|
return true;
|
2017-05-20 00:18:41 -04:00
|
|
|
},
|
|
|
|
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
/**
|
|
|
|
* Render preview.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
renderPreview: function renderPreview() {
|
2017-10-04 20:22:47 -04:00
|
|
|
var control = this, previewContainer, previewTemplate, attachmentId, attachmentUrl, poster, html = '', isOEmbed = false, mime, error, urlParser, matches;
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
attachmentId = control.model.get( 'attachment_id' );
|
|
|
|
attachmentUrl = control.model.get( 'url' );
|
|
|
|
error = control.model.get( 'error' );
|
|
|
|
|
|
|
|
if ( ! attachmentId && ! attachmentUrl ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify the selected attachment mime is supported.
|
|
|
|
mime = control.selectedAttachment.get( 'mime' );
|
|
|
|
if ( mime && attachmentId ) {
|
|
|
|
if ( ! _.contains( _.values( wp.media.view.settings.embedMimes ), mime ) ) {
|
|
|
|
error = 'unsupported_file_type';
|
|
|
|
}
|
2017-10-04 20:22:47 -04:00
|
|
|
} else if ( ! attachmentId ) {
|
|
|
|
urlParser = document.createElement( 'a' );
|
|
|
|
urlParser.href = attachmentUrl;
|
|
|
|
matches = urlParser.pathname.toLowerCase().match( /\.(\w+)$/ );
|
|
|
|
if ( matches ) {
|
|
|
|
if ( ! _.contains( _.keys( wp.media.view.settings.embedMimes ), matches[1] ) ) {
|
|
|
|
error = 'unsupported_file_type';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
isOEmbed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isOEmbed ) {
|
|
|
|
control.fetchEmbed();
|
|
|
|
if ( control.oembedResponses[ attachmentUrl ] ) {
|
|
|
|
poster = control.oembedResponses[ attachmentUrl ].thumbnail_url;
|
|
|
|
html = control.oembedResponses[ attachmentUrl ].html.replace( /\swidth="\d+"/, ' width="100%"' ).replace( /\sheight="\d+"/, '' );
|
|
|
|
}
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
previewContainer = control.$el.find( '.media-widget-preview' );
|
|
|
|
previewTemplate = wp.template( 'wp-media-widget-video-preview' );
|
|
|
|
|
2017-05-22 18:05:42 -04:00
|
|
|
previewContainer.html( previewTemplate({
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
model: {
|
2017-10-04 20:22:47 -04:00
|
|
|
attachment_id: attachmentId,
|
|
|
|
html: html,
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
src: attachmentUrl,
|
|
|
|
poster: poster
|
|
|
|
},
|
2017-10-04 20:22:47 -04:00
|
|
|
is_oembed: isOEmbed,
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
error: error
|
2017-05-22 18:05:42 -04:00
|
|
|
}));
|
2017-05-12 15:56:43 -04:00
|
|
|
wp.mediaelement.initialize();
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open the media image-edit frame to modify the selected item.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
editMedia: function editMedia() {
|
|
|
|
var control = this, mediaFrame, metadata, updateCallback;
|
|
|
|
|
|
|
|
metadata = control.mapModelToMediaFrameProps( control.model.toJSON() );
|
|
|
|
|
|
|
|
// Set up the media frame.
|
|
|
|
mediaFrame = new VideoDetailsMediaFrame({
|
|
|
|
frame: 'video',
|
|
|
|
state: 'video-details',
|
|
|
|
metadata: metadata
|
|
|
|
});
|
|
|
|
wp.media.frame = mediaFrame;
|
|
|
|
mediaFrame.$el.addClass( 'media-widget' );
|
|
|
|
|
|
|
|
updateCallback = function( mediaFrameProps ) {
|
|
|
|
|
|
|
|
// Update cached attachment object to avoid having to re-fetch. This also triggers re-rendering of preview.
|
|
|
|
control.selectedAttachment.set( mediaFrameProps );
|
|
|
|
|
|
|
|
control.model.set( _.extend(
|
|
|
|
_.omit( control.model.defaults(), 'title' ),
|
|
|
|
control.mapMediaToModelProps( mediaFrameProps ),
|
|
|
|
{ error: false }
|
|
|
|
) );
|
|
|
|
};
|
|
|
|
|
|
|
|
mediaFrame.state( 'video-details' ).on( 'update', updateCallback );
|
|
|
|
mediaFrame.state( 'replace-video' ).on( 'replace', updateCallback );
|
|
|
|
mediaFrame.on( 'close', function() {
|
|
|
|
mediaFrame.detach();
|
|
|
|
});
|
|
|
|
|
|
|
|
mediaFrame.open();
|
|
|
|
}
|
2017-05-22 18:05:42 -04:00
|
|
|
});
|
Widgets: Introduce media widgets for images, audio, and video with extensible base for additional media widgets in the future.
The last time a new widget was introduced, Vuvuzelas were a thing, Angry Birds started taking over phones, and WordPress stopped shipping with Kubrick. Seven years and 17 releases without new widgets have been enough, time to spice up your sidebar!
Props westonruter, melchoyce, obenland, timmydcrawford, adamsilverstein, gonom9, wonderboymusic, Fab1en, DrewAPicture, sirbrillig, joen, matias, samikeijonen, afercia, celloexpressions, designsimply, michelleweber, ranh, kjellr, karmatosed.
Fixes #32417, #39993, #39994, #39995.
Built from https://develop.svn.wordpress.org/trunk@40640
git-svn-id: http://core.svn.wordpress.org/trunk@40501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-11 17:11:44 -04:00
|
|
|
|
|
|
|
// Exports.
|
|
|
|
component.controlConstructors.media_video = VideoWidgetControl;
|
|
|
|
component.modelConstructors.media_video = VideoWidgetModel;
|
|
|
|
|
|
|
|
})( wp.mediaWidgets );
|