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

[stable30] fix(FilePreview): use original size for uploaded image files #13172

Merged
merged 3 commits into from
Aug 29, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,13 @@ export default {
},

imageContainerStyle() {
// Uploaded image in temporary message (use actual image size)
if (this.previewType === PREVIEW_TYPE.TEMPORARY && !this.isUploadEditor) {
return {}
}

// Fallback for loading mimeicons (preview for audio files is not provided)
if (this.file['preview-available'] !== 'yes' || this.file.mimetype.startsWith('audio/')) {
if (this.file['preview-available'] !== 'yes' || this.file.mimetype.startsWith('audio/') || this.failed) {
return {
width: this.smallPreview ? '32px' : '128px',
height: this.smallPreview ? '32px' : '128px',
Expand All @@ -293,12 +298,9 @@ export default {
const widthConstraint = this.smallPreview ? 32 : (this.mediumPreview ? 192 : 600)
const heightConstraint = this.smallPreview ? 32 : (this.mediumPreview ? 192 : 384)

// Fallback when no metadata available
// Actual size when no metadata available
if (!this.file.width || !this.file.height) {
return {
width: widthConstraint + 'px',
height: heightConstraint + 'px',
}
return {}
}

const sizeMultiplicator = Math.min(
Expand Down Expand Up @@ -587,7 +589,7 @@ export default {

.preview {
border-radius: var(--border-radius);
max-width: 100%;
max-width: min(100%, 600px);
max-height: 384px;
}

Expand Down
Loading