You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
733 B
JavaScript

"use strict";
const thumbnailImageBrowser = require("../thumbnail-image-browser");
const getThumbnail = require("../get-thumbnail");
module.exports = function thumbnailImage({ session, mxc, maximumWidth, maximumHeight, file, mimetype }) {
// TODO: localOnly option for encrypted images
if (typeof window !== "undefined" && window.HTMLImageElement != null) {
// Browser environments
return thumbnailImageBrowser({
file: file,
mimetype: mimetype,
maximumWidth: maximumWidth,
maximumHeight: maximumHeight,
});
} else {
// Server environments
return getThumbnail({
session: session,
url: mxc,
method: "fit",
minimumWidth: maximumWidth,
minimumHeight: maximumHeight,
stream: false
});
}
};