Merge pull request #932 from JCallicoat/videoplugin_imgur_fix
Make videoPlugin work for all imgur gifv videos
This commit is contained in:
commit
a49bc86554
1 changed files with 21 additions and 8 deletions
|
@ -281,8 +281,8 @@ plugins.factory('userPlugins', function() {
|
||||||
if (url.indexOf("^https?://fukung.net/v/") != -1) {
|
if (url.indexOf("^https?://fukung.net/v/") != -1) {
|
||||||
url = url.replace(/.*\//, "http://media.fukung.net/imgs/");
|
url = url.replace(/.*\//, "http://media.fukung.net/imgs/");
|
||||||
} else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) {
|
} else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) {
|
||||||
// remove protocol specification to load over https if used by g-b
|
// imgur: always use https. avoids mixed content warnings
|
||||||
url = url.replace(/http:/, "https:");
|
url = url.replace(/^http:/, "https:");
|
||||||
} else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)) {
|
} else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\//i)) {
|
||||||
// Dropbox requires a get parameter, dl=1
|
// Dropbox requires a get parameter, dl=1
|
||||||
var dbox_url = document.createElement("a");
|
var dbox_url = document.createElement("a");
|
||||||
|
@ -340,16 +340,29 @@ plugins.factory('userPlugins', function() {
|
||||||
var videoPlugin = new UrlPlugin('video', function(url) {
|
var videoPlugin = new UrlPlugin('video', function(url) {
|
||||||
if (url.match(/\.(3gp|avi|flv|gifv|mkv|mp4|ogv|webm|wmv)\b/i)) {
|
if (url.match(/\.(3gp|avi|flv|gifv|mkv|mp4|ogv|webm|wmv)\b/i)) {
|
||||||
if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) {
|
if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) {
|
||||||
// remove protocol specification to load over https if used by g-b
|
// imgur: always use https. avoids mixed content warnings
|
||||||
url = url.replace(/\.(gifv)\b/i, ".webm");
|
url = url.replace(/^http:/, "https:");
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
var element = this.getElement();
|
var element = this.getElement(), src;
|
||||||
var velement = angular.element('<video autoplay loop muted></video>')
|
var velement = angular.element('<video autoplay loop muted></video>')
|
||||||
.addClass('embed')
|
.addClass('embed')
|
||||||
.attr('width', '560')
|
.attr('width', '560');
|
||||||
.append(angular.element('<source></source>')
|
// imgur doesn't always have webm for gifv so add sources for webm and mp4
|
||||||
.attr('src', url));
|
if (url.match(/^https:\/\/(i\.)?imgur\.com\/.*\.gifv/i)) {
|
||||||
|
src = angular.element('<source></source>')
|
||||||
|
.attr('src', url.replace(/\.gifv\b/i, ".webm"))
|
||||||
|
.attr('type', 'video/webm');
|
||||||
|
velement.append(src);
|
||||||
|
src = angular.element('<source></source>')
|
||||||
|
.attr('src', url.replace(/\.gifv\b/i, ".mp4"))
|
||||||
|
.attr('type', 'video/mp4');
|
||||||
|
velement.append(src);
|
||||||
|
} else {
|
||||||
|
src = angular.element('<source></source>')
|
||||||
|
.attr('src', url);
|
||||||
|
velement.append(src);
|
||||||
|
}
|
||||||
element.innerHTML = velement.prop('outerHTML');
|
element.innerHTML = velement.prop('outerHTML');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue