Merge branch 'letterbox-aspect-excess' into 'develop'
Letterbox images with excess aspect ratios See merge request soapbox-pub/soapbox-fe!516
This commit is contained in:
commit
234d098d46
1 changed files with 12 additions and 1 deletions
|
@ -26,6 +26,17 @@ const mapStateToItemProps = state => ({
|
||||||
autoPlayGif: getSettings(state).get('autoPlayGif'),
|
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)
|
@connect(mapStateToItemProps)
|
||||||
class Item extends React.PureComponent {
|
class Item extends React.PureComponent {
|
||||||
|
|
||||||
|
@ -173,7 +184,7 @@ class Item extends React.PureComponent {
|
||||||
const previewUrl = attachment.get('preview_url');
|
const previewUrl = attachment.get('preview_url');
|
||||||
|
|
||||||
const originalUrl = attachment.get('url');
|
const originalUrl = attachment.get('url');
|
||||||
const letterboxed = !attachment.getIn(['meta', 'original', 'aspect']);
|
const letterboxed = shouldLetterbox(attachment);
|
||||||
|
|
||||||
thumbnail = (
|
thumbnail = (
|
||||||
<a
|
<a
|
||||||
|
|
Loading…
Reference in a new issue