diff --git a/app/css/app.css b/app/css/app.css index ddbca6d1..ef31e543 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -1067,7 +1067,20 @@ 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; + margin-top: 5px; +} +.im_message_iframe_video iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; +} .im_message_document, .im_message_audio, diff --git a/app/js/services.js b/app/js/services.js index 1daff0f5..1b3592bc 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -2427,6 +2427,7 @@ angular.module('myApp.services', []) } var regExp = new RegExp('((?:(ftp|https?)://|(?:mailto:)?([A-Za-z0-9._%+-]+@))(\\S*\\.\\S*[^\\s.;,(){}<>"\']))|(\\n)|(' + emojiUtf.join('|') + ')', 'i'); + var youtubeRegex = /(?:https?:\/\/)?(?:www\.)?youtu(?:|.be|be.com|.b)(?:\/v\/|\/watch\\?v=|e\/|\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/; return { wrapRichText: wrapRichText @@ -2545,6 +2546,16 @@ angular.module('myApp.services', []) } // console.log(4, text, html); + if (!options.noLinks) { + var youtubeMatches = text.match(youtubeRegex), + videoID = youtubeMatches && youtubeMatches[1]; + + if (videoID) { + text = text + '
' + } + } return $sce.trustAs('html', text); }