Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Set image sizes based on rotation #20531

Merged
merged 3 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/file-upload/server/lib/FileUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,18 @@ export const FileUpload = {
return fut.return();
}

const rotated = typeof metadata.orientation !== 'undefined' && metadata.orientation !== 1;

const identify = {
format: metadata.format,
size: {
width: metadata.width,
height: metadata.height,
width: rotated ? metadata.height : metadata.width,
height: rotated ? metadata.width : metadata.height,
},
};

const reorientation = (cb) => {
if (!metadata.orientation || metadata.orientation === 1 || settings.get('FileUpload_RotateImages') !== true) {
if (!rotated || settings.get('FileUpload_RotateImages') !== true) {
return cb();
}
s.rotate()
Expand Down
4 changes: 2 additions & 2 deletions client/components/Message/Attachments/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const Collapse: FC<ButtonProps & { collapsed?: boolean }> = ({ collapsed = false
return <Action title={collapsed ? t('Uncollapse') : t('Collapse')}icon={ !collapsed ? 'chevron-down' : 'chevron-left' }{...props} />;
};

const Download: FC<ButtonProps & { href: string }> = (props) => {
const Download: FC<ButtonProps & { href: string }> = ({ title, ...props }) => {
const t = useTranslation();
return <Action icon='download' title={t('Download')} is='a' target='_blank' {...props} />;
return <Action icon='download' title={t('Download')} is='a' target='_blank' download={title} {...props} />;
};

const Content: FC<BoxProps> = ({ ...props }) => <Box rcx-attachment__content width='full' mb='x4' {...props} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AudioAttachment: FC<AudioAttachmentProps> = ({
<Attachment.Title>{title}</Attachment.Title>
{size && <Attachment.Size size={size}/>}
{collapse}
{hasDownload && link && <Attachment.Download href={link}/>}
{hasDownload && link && <Attachment.Download title={title} href={link}/>}
</Attachment.Row>
{ !collapsed && <Attachment.Content border='none'>
<audio controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const GenericFileAttachment: FC<GenericFileAttachmentProps> = ({
<Attachment.Title { ...hasDownload && link && { is: 'a', href: link, color: undefined } } >{title}</Attachment.Title>
{size && <Attachment.Size size={size}/>}
{/* {collapse} */}
{hasDownload && link && <Attachment.Download href={link}/>}
{hasDownload && link && <Attachment.Download title={title} href={link}/>}
</Attachment.Row>
{/* { !collapsed && <Attachment.Content>
<Attachment.Details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const ImageAttachment: FC<ImageAttachmentProps> = ({
<Attachment.Title>{title}</Attachment.Title>
{size && <Attachment.Size size={size}/>}
{collapse}
{hasDownload && link && <Attachment.Download href={getURL(link)}/>}
{hasDownload && link && <Attachment.Download title={title} href={getURL(link)}/>}
</Attachment.Row>
{ !collapsed && <Attachment.Content>
<Image {...imageDimensions } loadImage={loadImage} setLoadImage={setLoadImage} src={ url} previewUrl={`data:image/png;base64,${ imagePreview }`} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const VideoAttachment: FC<VideoAttachmentProps> = ({ title,
<Attachment.Title>{title}</Attachment.Title>
{size && <Attachment.Size size={size}/>}
{collapse}
{hasDownload && link && <Attachment.Download href={link}/>}
{hasDownload && link && <Attachment.Download title={title} href={link}/>}
</Attachment.Row>
{ !collapsed && <Attachment.Content width='full'>
<Box is='video' width='full' controls>
Expand Down