Stop returning GIF URLs from _best_portrait_url
All checks were successful
Build plugin / build (push) Successful in 1m11s

When all available cover URLs are GIFs (coverUrl, stillCoverUrl, and
screenshots), return empty instead of a GIF URL. HTTPImageFetcher cannot
decode GIFs, so attempting to fetch one always returns null. Returning
empty early avoids unnecessary network requests and confusing log noise.
This commit is contained in:
Jose Falanga 2026-08-19 18:29:34 -03:00
parent 696123b55a
commit 658e8552cb
2 changed files with 7 additions and 4 deletions

View file

@ -174,6 +174,7 @@ func _url_for_layout(kind: LAYOUT, cover_url: String, screenshots: Array) -> Str
for url in screenshots: for url in screenshots:
if not _is_gif_url(url): if not _is_gif_url(url):
return url return url
# cover_url is already sanitized and non-GIF by the time it reaches here
return cover_url return cover_url
LAYOUT.BANNER: LAYOUT.BANNER:
# Single screenshot fallback (two-screenshot case handled in get_boxart). # Single screenshot fallback (two-screenshot case handled in get_boxart).
@ -187,7 +188,8 @@ func _url_for_layout(kind: LAYOUT, cover_url: String, screenshots: Array) -> Str
## Returns a non-GIF URL suitable for portrait/logo from the game data. ## Returns a non-GIF URL suitable for portrait/logo from the game data.
## Falls back through: stillCoverUrl → coverUrl (non-GIF) → first non-GIF ## Falls back through: stillCoverUrl → coverUrl (non-GIF) → first non-GIF
## screenshot. ## screenshot. Returns empty if only GIFs are available, since
## HTTPImageFetcher cannot decode GIF images.
func _best_portrait_url(game: Dictionary, screenshots: Array) -> String: func _best_portrait_url(game: Dictionary, screenshots: Array) -> String:
# Prefer stillCoverUrl if it's not a GIF # Prefer stillCoverUrl if it's not a GIF
var still: String = game.get("stillCoverUrl", "") var still: String = game.get("stillCoverUrl", "")
@ -201,8 +203,9 @@ func _best_portrait_url(game: Dictionary, screenshots: Array) -> String:
for url in screenshots: for url in screenshots:
if not _is_gif_url(url): if not _is_gif_url(url):
return url return url
# Last resort: use whatever we have (GIF) # All available URLs are GIFs — return empty so the caller gets null
return still if not still.is_empty() else cover # instead of attempting a doomed fetch.
return ""
## Combines two textures side-by-side into a single banner image. ## Combines two textures side-by-side into a single banner image.

View file

@ -1,7 +1,7 @@
{ {
"plugin.id": "itch-artprovider", "plugin.id": "itch-artprovider",
"plugin.name": "itch.io Art Provider", "plugin.name": "itch.io Art Provider",
"plugin.version": "0.1.8", "plugin.version": "0.1.9",
"plugin.min-api-version": "1.1.0", "plugin.min-api-version": "1.1.0",
"plugin.link": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin", "plugin.link": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin",
"plugin.source": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin", "plugin.source": "https://forge.thergic.ar/jose/itchio-opengamepadui-artprovider-plugin",