From 1235a5e1482dec40fb7aaf68cfd5dda20cd3313d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:37:45 +0100 Subject: [PATCH 1/2] Embed Dropbox images We need to pass a parameter, "?dl=1", to get the actual file --- js/plugins.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/js/plugins.js b/js/plugins.js index 0f356ce..4230365 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -259,6 +259,9 @@ plugins.factory('userPlugins', function() { } else if (url.match(/^http:\/\/(i\.)?imgur\.com\//i)) { // remove protocol specification to load over https if used by g-b url = url.replace(/http:/, ""); + } else if (url.match(/^https:\/\/www\.dropbox\.com\/s\/[a-z0-9]+\/[^?]+$/i)) { + // Dropbox requires a get parameter, dl=1 + url = url + "?dl=1"; } return ''; From b939bc7ca8d189af19efad90d38ff49479964ab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCbschle-Schneider?= Date: Mon, 18 Aug 2014 16:41:30 +0100 Subject: [PATCH 2/2] Check GET parameters in image embedding This is a great candidate for the tests! --- js/plugins.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/js/plugins.js b/js/plugins.js index 4230365..d5f1bc4 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -251,8 +251,14 @@ plugins.factory('userPlugins', function() { */ var imagePlugin = new Plugin( urlPlugin(function(url) { - if (url.match(/\.(png|gif|jpg|jpeg)$/i)) { - + var embed = false; + // Check the get parameters as well, they might contain an image to load + var segments = url.split(/[?&]/).forEach(function(param) { + if (param.match(/\.(png|gif|jpg|jpeg)$/i)) { + embed = true; + } + }); + if (embed) { /* A fukung.net URL may end by an image extension but is not a direct link. */ if (url.indexOf("^https?://fukung.net/v/") != -1) { url = url.replace(/.*\//, "http://media.fukung.net/imgs/");