diff --git a/NextcloudTalk/BaseChatTableViewCell+File.swift b/NextcloudTalk/BaseChatTableViewCell+File.swift index 4a1b4c904..f9d49c32b 100644 --- a/NextcloudTalk/BaseChatTableViewCell+File.swift +++ b/NextcloudTalk/BaseChatTableViewCell+File.swift @@ -152,12 +152,17 @@ extension BaseChatTableViewCell { self.filePreviewActivityIndicator?.isHidden = true self.filePreviewActivityIndicator?.stopAnimating() - imageView.layer.borderColor = UIColor.secondarySystemFill.cgColor - imageView.layer.borderWidth = 1 - let imageSize = CGSize(width: image.size.width * image.scale, height: image.size.height * image.scale) let previewSize = BaseChatTableViewCell.getPreviewSize(from: imageSize, isMediaFile) + if !previewSize.width.isFinite || !previewSize.height.isFinite { + self.showFallbackIcon(for: message) + return + } + + imageView.layer.borderColor = UIColor.secondarySystemFill.cgColor + imageView.layer.borderWidth = 1 + self.filePreviewImageViewHeightConstraint?.constant = previewSize.height self.filePreviewImageViewWidthConstraint?.constant = previewSize.width