MyBB Community Forums

Full Version: Youtube video to the first place in editor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, 

I'm trying to edit "Insert a video" function in editor.

I want only that when I click on image of insert a video, Youtube is to the first place instead of Daily Motion.

I have edited in this way:

html: function(token, attrs, content) {
			var	matches, url,
				html = {
					youtube: '<iframe width="560" height="315" src="{url}" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>'
					dailymotion: '<iframe frameborder="0" width="480" height="270" src="{url}" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					facebook: '<iframe src="{url}" width="625" height="350" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					liveleak: '<iframe width="500" height="300" src="{url}" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					metacafe: '<iframe src="{url}" width="440" height="248" frameborder=0 data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					veoh: '<iframe src="{url}" width="410" height="341" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
					vimeo: '<iframe src="{url}" width="500" height="281" frameborder="0" data-mybb-vt="{type}" data-mybb-vsrc="{src}"></iframe>',
				};


if(html[attrs.defaultattr])
			{
				switch(attrs.defaultattr)
				{
					case 'youtube':
						matches = content.match(/(?:v=|v\/|embed\/|youtu\.be\/)(.{11})/);
						url     = matches ? '//www.youtube.com/embed/' + matches[1] : false;
						break;
					case 'dailymotion':
						matches = content.match(/dailymotion\.com\/video\/([^_]+)/);
						url     = matches ? 'http://www.dailymotion.com/embed/video/' + matches[1] : false;
						break;
					case 'facebook':
						matches = content.match(/facebook\.com\/(?:photo.php\?v=|video\/video.php\?v=|video\/embed\?video_id=|v\/?)(\d+)/);
						url     = matches ? 'https://www.facebook.com/video/embed?video_id=' + matches[1] : false;
						break;
					case 'liveleak':
						matches = content.match(/liveleak\.com\/(?:view\?i=)([^\/]+)/);
						url     = matches ? 'http://www.liveleak.com/ll_embed?i=' + matches[1] : false;
						break;
					case 'metacafe':
						matches = content.match(/metacafe\.com\/watch\/([^\/]+)/);
						url     = matches ? 'http://www.metacafe.com/embed/' + matches[1] : false;
						break;
					case 'veoh':
						matches = content.match(/veoh\.com\/watch\/([^\/]+)/);
						url     = matches ? '//www.veoh.com/swf/webplayer/WebPlayer.swf?videoAutoPlay=0&permalinkId=' + matches[1] : false;
						break;
					case 'vimeo':
						matches = content.match(/vimeo.com\/(\d+)($|\/)/);
						url     = matches ? '//player.vimeo.com/video/' + matches[1] : false;
						break;
				}


'<div>' +
					'<label for="videotype">' + editor._('Video Type:') + '</label> ' +
					'<select id="videotype">' +
						'<option value="youtube">' + editor._('Youtube') + '</option>' +
						'<option value="facebook">' + editor._('Facebook') + '</option>' +
						'<option value="liveleak">' + editor._('LiveLeak') + '</option>' +
						'<option value="metacafe">' + editor._('MetaCafe') + '</option>' +
						'<option value="veoh">' + editor._('Veoh') + '</option>' +
						'<option value="vimeo">' + editor._('Vimeo') + '</option>' +
						'<option value="dailymotion">' + editor._('Dailymotion') + '</option>' +
					'</select>'+
				'</div>' +

// Excludes MySpace TV and Yahoo Video as I couldn't actually find them. Maybe they are gone now?
			$content = $(
				'<div>' +
					'<label for="videotype">' + editor._('Video Type:') + '</label> ' +
					'<select id="videotype">' +
						'<option value="youtube">' + editor._('Youtube') + '</option>' +
						'<option value="facebook">' + editor._('Facebook') + '</option>' +
						'<option value="liveleak">' + editor._('LiveLeak') + '</option>' +
						'<option value="metacafe">' + editor._('MetaCafe') + '</option>' +
						'<option value="veoh">' + editor._('Veoh') + '</option>' +
						'<option value="vimeo">' + editor._('Vimeo') + '</option>' +
						'<option value="dailymotion">' + editor._('Dailymotion') + '</option>' +
					'</select>'+
				'</div>' +
The result is that image of insert a video is disappeared Sad how can I do it?
Thank you!