Commit 94af11d7 authored by Ariel Fuggini's avatar Ariel Fuggini Committed by JC Brand

adds setting to set non-image-extension image urls

parent 4d9d3913
......@@ -67,6 +67,7 @@ converse.plugins.add('converse-chatview', {
'emoji': true,
'spoiler': true
},
'image_urls_regex': null
});
......
......@@ -120,7 +120,7 @@ function addHyperlinks (text, onImgLoad, onImgClick) {
text.addTemplateResult(
url_obj.start,
url_obj.end,
show_images && u.isImageURL(url_text) ?
show_images && (u.isImageURL(url_text) || u.isWhitelistedImageURL(url_text)) ?
u.convertToImageTag(url_text, onImgLoad, onImgClick) :
u.convertUrlToHyperlink(url_text),
);
......
......@@ -75,8 +75,12 @@ function checkFileTypes (types, url) {
}
u.isAudioURL = url => checkFileTypes(['.ogg', '.mp3', '.m4a'], url);
u.isImageURL = url => checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url);
u.isVideoURL = url => checkFileTypes(['.mp4', '.webm'], url);
u.isImageURL = url => checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url);
u.isWhitelistedImageURL = url => {
const regex = _converse.api.settings.get('image_urls_regex');
return regex ? regex.test(url) : false;
}
function getFileName (uri) {
try {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment