Mercurial > eldonilo > avatar
changeset 5:9b2f17ea1594
Add an option to guess the type of an avatar even if it is unspecified.
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Thu, 19 May 2011 17:27:37 +0200 |
| parents | 8acaa0a575c7 |
| children | 3b799c33ab16 |
| files | avatar.js configuration.js |
| diffstat | 2 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/avatar.js +++ b/avatar.js @@ -146,8 +146,12 @@ try { var type = photo.getChild('TYPE', 'vcard-temp').getText(); } catch (e) { - svgError(res, 'Error: this user’s vCard doesn’t specify the MIME type of its avatar.'); - return; + if (config.guessType) + type = 'image/png'; // FIXME: use magic. + else { + svgError(res, 'Error: this user’s vCard doesn’t specify the MIME type of its avatar.'); + return; + } } var ext; @@ -155,8 +159,9 @@ if (type == extensions[i]) ext = i; + // Here we don’t try to guess the extension even if the option is set. if (ext === undefined) { - console.log('Type MIME inconnu : '+type); + console.log('Unknown MIME type: '+type); svgError(res, 'Error: this user’s avatar is in an unknown format.'); return; }