Fix not detecting .jpeg files as images

This commit is contained in:
chylex 2018-02-16 17:11:53 +01:00
parent fe065a50d8
commit c05f90c31e

View File

@ -17,6 +17,12 @@ var DISCORD = (function(){
mentionChannel: /<#(\d+?)>/g mentionChannel: /<#(\d+?)>/g
}; };
var isImageAttachment = function(attachment){
var dot = attachment.url.lastIndexOf(".");
var ext = dot === -1 ? "" : attachment.url.substring(dot).toLowerCase();
return ext === ".png" || ext === ".gif" || ext === ".jpg" || ext === ".jpeg";
};
var templateChannelServer; var templateChannelServer;
var templateChannelPrivate; var templateChannelPrivate;
var templateMessage; var templateMessage;
@ -138,9 +144,7 @@ var DISCORD = (function(){
} }
return value.map(attachment => { return value.map(attachment => {
var ext = attachment.url.slice(-4).toLowerCase(); if (isImageAttachment(attachment) && STATE.settings.enableImagePreviews){
if ((ext === ".png" || ext === ".gif" || ext === ".jpg" || ext === ".jpeg") && STATE.settings.enableImagePreviews){
return templateEmbedImage.apply(attachment); return templateEmbedImage.apply(attachment);
} }
else{ else{