From d28e257567046fde1761493b548119dba11caf12 Mon Sep 17 00:00:00 2001 From: alcomposer Date: Tue, 3 Dec 2024 12:20:00 +1030 Subject: [PATCH 1/2] Use findFiles to return _thumb images associated with the patch file --- Source/Components/WelcomePanel.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/Source/Components/WelcomePanel.h b/Source/Components/WelcomePanel.h index bb2a6b91f..793c208ab 100644 --- a/Source/Components/WelcomePanel.h +++ b/Source/Components/WelcomePanel.h @@ -796,19 +796,16 @@ class WelcomePanel : public Component libraryTiles.clear(); auto addTile = [this](File& patchFile){ - auto patchThumbnailBase = File(patchFile.getParentDirectory().getFullPathName() + "\\" + patchFile.getFileNameWithoutExtension() + "_thumb"); - StringArray possibleExtensions { ".png", ".jpg", ".jpeg", ".gif" }; + auto pName = patchFile.getFileNameWithoutExtension(); + auto foundThumbs = patchFile.getParentDirectory().findChildFiles(File::findFiles, true, pName + "_thumb.png;" + pName + "_thumb.jpg;" + pName + "_thumb.jpeg;" + pName + "_thumb.gif"); float scale = 1.0f; Image thumbImage; - for (auto& ext : possibleExtensions) { - auto patchThumbnail = patchThumbnailBase.withFileExtension(ext); - if (patchThumbnail.existsAsFile()) { - FileInputStream fileStream(patchThumbnail); - if (fileStream.openedOk()) { - thumbImage = ImageFileFormat::loadFrom(fileStream).convertedToFormat(Image::ARGB); - break; - } + for (auto& thumb: foundThumbs) { + FileInputStream fileStream(thumb); + if (fileStream.openedOk()) { + thumbImage = ImageFileFormat::loadFrom(fileStream).convertedToFormat(Image::ARGB); + break; } } String placeholderIcon; From 8d864052463f0ee9277ec5f001642ea4bc9e2866 Mon Sep 17 00:00:00 2001 From: alcomposer Date: Tue, 3 Dec 2024 12:22:28 +1030 Subject: [PATCH 2/2] Continue testing returned _thumb images if a valid image file hasn't been found --- Source/Components/WelcomePanel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Components/WelcomePanel.h b/Source/Components/WelcomePanel.h index 793c208ab..ec7e79072 100644 --- a/Source/Components/WelcomePanel.h +++ b/Source/Components/WelcomePanel.h @@ -805,7 +805,8 @@ class WelcomePanel : public Component FileInputStream fileStream(thumb); if (fileStream.openedOk()) { thumbImage = ImageFileFormat::loadFrom(fileStream).convertedToFormat(Image::ARGB); - break; + if (thumbImage.isValid()) + break; } } String placeholderIcon;