RichTextProcessor can embed Youtube videos as iframe; Fix #149
This commit is contained in:
parent
4cf02d4184
commit
c2647692df
@ -1067,7 +1067,19 @@ div.im_message_video_thumb {
|
||||
background-image: url(../img/icons/IconsetW_1x.png);
|
||||
}
|
||||
|
||||
|
||||
.im_message_iframe_video {
|
||||
position: relative;
|
||||
padding-bottom: 56.25%; // 16/9 ratio
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.im_message_iframe_video iframe, object, embed {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.im_message_document,
|
||||
.im_message_audio,
|
||||
|
@ -2545,6 +2545,13 @@ angular.module('myApp.services', [])
|
||||
}
|
||||
|
||||
// console.log(4, text, html);
|
||||
var youtubeRegex = /(?:https?:\/\/)?(?:www\.)?youtu(?:|.be|be.com|.b)(?:\/v\/|\/watch\\?v=|e\/|\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;
|
||||
if (!options.noLinks && youtubeRegex.test(text)) {
|
||||
var videoID = youtubeRegex.exec(text)[1];
|
||||
text = text + '<div class="im_message_iframe_video"><iframe type="text/html" frameborder="0" ' +
|
||||
'src="http://www.youtube.com/embed/' + videoID +
|
||||
'?autoplay=0&"></iframe></div>';
|
||||
}
|
||||
|
||||
return $sce.trustAs('html', text);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user