Cap blurhash image size at 32x32
This commit is contained in:
parent
77a6654ff2
commit
e0ffa1d9c5
|
@ -100,13 +100,17 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell {
|
|||
guard let hash = card.blurhash else {
|
||||
return
|
||||
}
|
||||
let imageViewSize = self.thumbnailView.bounds.size
|
||||
AttachmentView.queue.async { [weak self] in
|
||||
let size: CGSize
|
||||
if let width = card.width, let height = card.height {
|
||||
size = CGSize(width: width, height: height)
|
||||
let aspectRatio = CGFloat(width) / CGFloat(height)
|
||||
if aspectRatio > 1 {
|
||||
size = CGSize(width: 32, height: 32 / aspectRatio)
|
||||
} else {
|
||||
size = CGSize(width: 32 * aspectRatio, height: 32)
|
||||
}
|
||||
} else {
|
||||
size = imageViewSize
|
||||
size = CGSize(width: 32, height: 32)
|
||||
}
|
||||
|
||||
guard let preview = UIImage(blurHash: hash, size: size) else {
|
||||
|
|
|
@ -143,13 +143,17 @@ class TrendingLinkTableViewCell: UITableViewCell {
|
|||
guard let hash = card.blurhash else {
|
||||
return
|
||||
}
|
||||
let imageViewSize = self.thumbnailView.bounds.size
|
||||
AttachmentView.queue.async { [weak self] in
|
||||
let size: CGSize
|
||||
if let width = card.width, let height = card.height {
|
||||
size = CGSize(width: width, height: height)
|
||||
let aspectRatio = CGFloat(width) / CGFloat(height)
|
||||
if aspectRatio > 1 {
|
||||
size = CGSize(width: 32, height: 32 / aspectRatio)
|
||||
} else {
|
||||
size = CGSize(width: 32 * aspectRatio, height: 32)
|
||||
}
|
||||
} else {
|
||||
size = imageViewSize
|
||||
size = CGSize(width: 32, height: 32)
|
||||
}
|
||||
|
||||
guard let preview = UIImage(blurHash: hash, size: size) else {
|
||||
|
|
|
@ -168,16 +168,19 @@ class StatusCardView: UIView {
|
|||
private func loadBlurHash() {
|
||||
guard let card = card, let hash = card.blurhash else { return }
|
||||
|
||||
let imageViewSize = self.imageView.bounds.size
|
||||
|
||||
AttachmentView.queue.async { [weak self] in
|
||||
guard let self = self else { return }
|
||||
|
||||
let size: CGSize
|
||||
if let width = card.width, let height = card.height {
|
||||
size = CGSize(width: width, height: height)
|
||||
let aspectRatio = CGFloat(width) / CGFloat(height)
|
||||
if aspectRatio > 1 {
|
||||
size = CGSize(width: 32, height: 32 / aspectRatio)
|
||||
} else {
|
||||
size = CGSize(width: 32 * aspectRatio, height: 32)
|
||||
}
|
||||
} else {
|
||||
size = imageViewSize
|
||||
size = CGSize(width: 32, height: 32)
|
||||
}
|
||||
|
||||
guard let preview = UIImage(blurHash: hash, size: size) else {
|
||||
|
|
Loading…
Reference in New Issue