Commit 158f3f00 authored by JC Brand's avatar JC Brand

utils/html: expose more methods

parent ef1f16c1
......@@ -94,9 +94,9 @@ function checkFileTypes (types, url) {
return !!types.filter(ext => filename.endsWith(ext)).length;
}
const isAudioURL = url => checkFileTypes(['.ogg', '.mp3', '.m4a'], url);
const isImageURL = url => checkFileTypes(['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff', '.svg'], url);
const isVideoURL = url => checkFileTypes(['.mp4', '.webm'], 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);
function getFileName (uri) {
try {
......@@ -146,11 +146,11 @@ u.getOOBURLMarkup = function (_converse, url) {
if (uri === null) {
return url;
}
if (isVideoURL(uri)) {
if (u.isVideoURL(uri)) {
return tpl_video({url})
} else if (isAudioURL(uri)) {
} else if (u.isAudioURL(uri)) {
return renderAudioURL(_converse, uri);
} else if (isImageURL(uri)) {
} else if (u.isImageURL(uri)) {
return renderImageURL(_converse, uri);
} else {
return renderFileURL(_converse, uri);
......@@ -197,7 +197,7 @@ u.renderImageURLs = function (_converse, el) {
return Promise.all(
list.map(url =>
new Promise((resolve) => {
if (isImageURL(url)) {
if (u.isImageURL(url)) {
return isImage(url).then(img => {
const i = new Image();
i.src = img.src;
......
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