Changeset 40810
- Timestamp:
- 05/20/2017 04:17:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r40631 r40810 330 330 cwd: SOURCE_DIR, 331 331 src: [ 332 'wp-admin/js/* .js',332 'wp-admin/js/**/*.js', 333 333 'wp-includes/js/*.js', 334 334 // Built scripts. -
trunk/src/wp-admin/js/widgets/media-video-widget.js
r40656 r40810 136 136 137 137 /** 138 * Whether a url is a supported external host. 139 * 140 * @param {String} url - Video url. 141 * @returns {boolean} Whether url is a supported video host. 142 */ 143 isHostedVideo: function isHostedVideo( url ) { 144 var parsedUrl = document.createElement( 'a' ); 145 parsedUrl.href = url; 146 return /vimeo|youtu\.?be/.test( parsedUrl.host ); 147 }, 148 149 /** 138 150 * Render preview. 139 151 * … … 151 163 152 164 if ( ! attachmentId && attachmentUrl ) { 153 parsedUrl = document.createElement( 'a' ); 154 parsedUrl.href = attachmentUrl; 155 isHostedEmbed = /vimeo|youtu\.?be/.test( parsedUrl.host ); 165 isHostedEmbed = control.isHostedVideo( attachmentUrl ); 156 166 } 157 167 -
trunk/tests/qunit/wp-admin/js/widgets/test-media-video-widget.js
r40640 r40810 33 33 equal( mappedProps.loop, false, 'mapMediaToModelProps should set loop' ); 34 34 equal( mappedProps.preload, 'meta', 'mapMediaToModelProps should set preload' ); 35 36 // Test isHostedVideo(). 37 equal( videoWidgetControlInstance.isHostedVideo( 'https://www.youtube.com/watch?v=OQSNhk5ICTI' ), true, 'isHostedVideo should return true for full YouTube url.' ); 38 equal( videoWidgetControlInstance.isHostedVideo( 'https://youtu.be/OQSNhk5ICTI' ), true, 'isHostedVideo should return true for shortened youtube url' ); 39 equal( videoWidgetControlInstance.isHostedVideo( 'https://vimeo.com/190372437' ), true, 'isHostedVideo should return true for vimeo url.' ); 40 equal( videoWidgetControlInstance.isHostedVideo( 'https://wordpress.org/' ), false, 'isHostedVideo should return false for non-supported video url.' ); 35 41 }); 36 42
Note: See TracChangeset
for help on using the changeset viewer.