Vernissage/CoreData/AttachmentData+HighestImage...

25 lines
587 B
Swift
Raw Normal View History

2023-01-27 15:46:09 +01:00
//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
2023-03-28 10:35:38 +02:00
// Licensed under the Apache License 2.0.
2023-01-27 15:46:09 +01:00
//
2023-01-27 15:46:09 +01:00
import Foundation
extension [AttachmentData] {
func getHighestImage() -> AttachmentData? {
var attachment = self.first
var imgHeight = 0.0
for item in self {
let attachmentheight = Double(item.metaImageHeight)
if attachmentheight > imgHeight {
attachment = item
imgHeight = attachmentheight
}
}
2023-01-27 15:46:09 +01:00
return attachment
}
}