Letterbox images with excess aspect ratios

merge-requests/516/head
Alex Gleason 2021-05-30 14:21:52 -05:00
rodzic da630ab8c2
commit 47f6376e3e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -26,6 +26,17 @@ const mapStateToItemProps = state => ({
autoPlayGif: getSettings(state).get('autoPlayGif'),
});
const withinLimits = aspectRatio => {
return aspectRatio >= minimumAspectRatio && aspectRatio <= maximumAspectRatio;
};
const shouldLetterbox = attachment => {
const aspectRatio = attachment.getIn(['meta', 'original', 'aspect']);
if (!aspectRatio) return true;
return !withinLimits(aspectRatio);
};
@connect(mapStateToItemProps)
class Item extends React.PureComponent {
@ -173,7 +184,7 @@ class Item extends React.PureComponent {
const previewUrl = attachment.get('preview_url');
const originalUrl = attachment.get('url');
const letterboxed = !attachment.getIn(['meta', 'original', 'aspect']);
const letterboxed = shouldLetterbox(attachment);
thumbnail = (
<a