plugins: (image) support fukung.net

Links to http://fukung.net/v/foobar.gif end by the actual image
extensions, but the full image path is under
http://media.fukung.net/imgs/foobar.gif.

This commit replace the URL prefix if it matches fukung.net/v/.
This commit is contained in:
Vivien Didelot 2013-10-17 18:20:04 -04:00
parent ea65c5dc44
commit 55b720466b
1 changed files with 15 additions and 7 deletions

View File

@ -150,16 +150,24 @@ plugins.factory('userPlugins', function() {
* Image Preview
*/
var imagePlugin = new Plugin(function(message) {
var url = message.match(urlRegexp);
if (url) {
var url = url[0]; /* Actually parse one url per message */
var url = message.match(urlRegexp);
var content = null;
if (url) {
var url = url[0]; /* Actually parse one url per message */
if (url.match(/png$|gif$|jpg$|jpeg$/)) {
return '<img src="' + url + '" height="300">';
}
/* A fukung.net URL may end by an image extension but is not a direct link. */
if (url.indexOf("fukung.net/v/") != -1) {
url = url.replace(/.*\//, "http://media.fukung.net/imgs/")
}
content = '<img src="' + url + '" height="300">';
}
}
return null;
return content;
});
imagePlugin.name = 'image';