Skip to content

Commit

Permalink
If there are no image tags don't build a url
Browse files Browse the repository at this point in the history
  • Loading branch information
chickdan committed Oct 24, 2023
1 parent 18b06ff commit ec5e0fa
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Shared/Extensions/JellyfinAPI/BaseItemDto+Images.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ extension BaseItemDto {
_ type: ImageType,
maxWidth: Int? = nil,
maxHeight: Int? = nil
) -> URL {
) -> URL? {
_imageURL(type, maxWidth: maxWidth, maxHeight: maxHeight, itemID: id ?? "")
}

func imageURL(
_ type: ImageType,
maxWidth: CGFloat? = nil,
maxHeight: CGFloat? = nil
) -> URL {
) -> URL? {
_imageURL(type, maxWidth: Int(maxWidth), maxHeight: Int(maxHeight), itemID: id ?? "")
}

Expand All @@ -52,11 +52,11 @@ extension BaseItemDto {

// MARK: Series Images

func seriesImageURL(_ type: ImageType, maxWidth: Int? = nil, maxHeight: Int? = nil) -> URL {
func seriesImageURL(_ type: ImageType, maxWidth: Int? = nil, maxHeight: Int? = nil) -> URL? {
_imageURL(type, maxWidth: maxWidth, maxHeight: maxHeight, itemID: seriesID ?? "")
}

func seriesImageURL(_ type: ImageType, maxWidth: CGFloat? = nil, maxHeight: CGFloat? = nil) -> URL {
func seriesImageURL(_ type: ImageType, maxWidth: CGFloat? = nil, maxHeight: CGFloat? = nil) -> URL? {
_imageURL(type, maxWidth: Int(maxWidth), maxHeight: Int(maxHeight), itemID: seriesID ?? "")
}

Expand All @@ -80,11 +80,13 @@ extension BaseItemDto {
maxWidth: Int?,
maxHeight: Int?,
itemID: String
) -> URL {
) -> URL? {
guard let imageTags = imageTags else { return nil }

// TODO: See if the scaling is actually right so that it isn't so big
let scaleWidth = maxWidth == nil ? nil : UIScreen.main.scale(maxWidth!)
let scaleHeight = maxHeight == nil ? nil : UIScreen.main.scale(maxHeight!)
let tag = imageTags?[type.rawValue]
let tag = imageTags[type.rawValue]

let client = Container.userSession.callAsFunction().client
let parameters = Paths.GetItemImageParameters(
Expand Down

0 comments on commit ec5e0fa

Please sign in to comment.