Impressia/Vernissage/Extensions/Status+ImageSize.swift
2023-01-09 13:05:02 +01:00

27 lines
674 B
Swift

//
// https://mczachurski.dev
// Copyright © 2023 Marcin Czachurski and the repository contributors.
// Licensed under the MIT License.
//
import Foundation
import MastodonSwift
extension Status {
public func getImageWidth() -> Int32? {
if let width = (self.mediaAttachments.first?.meta as? ImageMetadata)?.original?.width {
return Int32(width)
} else {
return nil
}
}
public func getImageHeight() -> Int32? {
if let height = (self.mediaAttachments.first?.meta as? ImageMetadata)?.original?.height {
return Int32(height)
} else {
return nil
}
}
}