adds setting to set non-image-extension image urls

This commit is contained in:
Ariel Fuggini 2020-08-27 15:04:23 -05:00 committed by JC Brand
parent 4d9d391365
commit 94af11d7e3
3 changed files with 7 additions and 2 deletions

View File

@ -67,6 +67,7 @@ converse.plugins.add('converse-chatview', {
'emoji': true,
'spoiler': true
},
'image_urls_regex': null
});

View File

@ -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),
);

View File

@ -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 {