stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
39 lines • 1.28 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.buildThumbnail = buildThumbnail;
var _getResizedImageUrl = require("../../../../utils/getResizedImageUrl");
var _getUrlOfImageAttachment = require("../../../../utils/getUrlOfImageAttachment");
function buildThumbnail({
height,
image,
resizableCDNHosts,
resizeMode,
width,
flex
}) {
var originalImageHeight = image.original_height,
originalImageWidth = image.original_width;
var shouldResize = originalImageHeight && originalImageWidth ? originalImageHeight + originalImageWidth > height + width : true;
var imageUrl = (0, _getUrlOfImageAttachment.getUrlOfImageAttachment)(image);
var localId = image.localId;
return {
flex,
localId,
resizeMode: resizeMode ? resizeMode : image.original_height && image.original_width ? 'contain' : 'cover',
thumb_url: image.thumb_url && shouldResize ? (0, _getResizedImageUrl.getResizedImageUrl)({
height,
resizableCDNHosts,
url: image.thumb_url,
width
}) : image.thumb_url,
type: image.type,
url: shouldResize ? (0, _getResizedImageUrl.getResizedImageUrl)({
height,
resizableCDNHosts,
url: imageUrl,
width
}) : imageUrl
};
}
//# sourceMappingURL=buildThumbnail.js.map