From fe354659a29ea4b538414c7e3f2c17a952d32e09 Mon Sep 17 00:00:00 2001 From: zoltanvb Date: Sun, 21 Jul 2024 16:05:09 +0200 Subject: [PATCH] Try for non-PNG thumbnails as well. --- gfx/gfx_thumbnail_path.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/gfx/gfx_thumbnail_path.c b/gfx/gfx_thumbnail_path.c index 3fd043113544..cb881b1813c4 100644 --- a/gfx/gfx_thumbnail_path.c +++ b/gfx/gfx_thumbnail_path.c @@ -573,6 +573,9 @@ bool gfx_thumbnail_update_path( const char *system_name = NULL; char *thumbnail_path = NULL; const char *dir_thumbnails = NULL; + /* Thumbnail extension order. The default (i.e. png) is always the first. */ + #define MAX_SUPPORTED_THUMBNAIL_EXTENSIONS 5 + const char* const SUPPORTED_THUMBNAIL_EXTENSIONS[] = { ".png", ".jpg", ".jpeg", ".bmp", ".tga", 0 }; if (!path_data) return false; @@ -648,6 +651,8 @@ bool gfx_thumbnail_update_path( char tmp_buf[PATH_MAX_LENGTH]; const char *type = gfx_thumbnail_get_type(settings, path_data, thumbnail_id); + int i; + bool thumbnail_found = false; /* > Normal content: assemble path */ /* >> Base + system name */ @@ -663,19 +668,38 @@ bool gfx_thumbnail_update_path( fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img_full, PATH_MAX_LENGTH * sizeof(char)); } + thumbnail_found = path_is_valid(thumbnail_path); + /* Try alternative file extensions in turn */ + for(i=1;i> Add content image - second try with label (database name) */ - if(!path_is_valid(thumbnail_path) && path_data->content_img[0] != '\0') + if(!thumbnail_found && path_data->content_img[0] != '\0') { thumbnail_path[0] = '\0'; fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img, PATH_MAX_LENGTH * sizeof(char)); + thumbnail_found = path_is_valid(thumbnail_path); + } + for(i=1;i> Add content image - third try with shortened name (title only) */ - if(!path_is_valid(thumbnail_path) && path_data->content_img_short[0] != '\0') + if(!thumbnail_found && path_data->content_img_short[0] != '\0') { thumbnail_path[0] = '\0'; fill_pathname_join_special(thumbnail_path, tmp_buf, path_data->content_img_short, PATH_MAX_LENGTH * sizeof(char)); + thumbnail_found = path_is_valid(thumbnail_path); + } + for(i=1;i