From 10f8ff8b22d59a6da4abb2d9238ba7727b55f35e Mon Sep 17 00:00:00 2001 From: CaptainFrito Date: Mon, 26 Jan 2026 10:42:19 +0700 Subject: [PATCH] Generate empty thumbnail for books without a cover --- lib/Epub/Epub.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Epub/Epub.cpp b/lib/Epub/Epub.cpp index ecfc8f95..4101614f 100644 --- a/lib/Epub/Epub.cpp +++ b/lib/Epub/Epub.cpp @@ -435,11 +435,8 @@ bool Epub::generateThumbBmp(int height) const { const auto coverImageHref = bookMetadataCache->coreMetadata.coverItemHref; if (coverImageHref.empty()) { Serial.printf("[%lu] [EBP] No known cover image for thumbnail\n", millis()); - return false; - } - - if (coverImageHref.substr(coverImageHref.length() - 4) == ".jpg" || - coverImageHref.substr(coverImageHref.length() - 5) == ".jpeg") { + } else if (coverImageHref.substr(coverImageHref.length() - 4) == ".jpg" || + coverImageHref.substr(coverImageHref.length() - 5) == ".jpeg") { Serial.printf("[%lu] [EBP] Generating thumb BMP from JPG cover image\n", millis()); const auto coverJpgTempPath = getCachePath() + "/.cover.jpg"; @@ -480,6 +477,10 @@ bool Epub::generateThumbBmp(int height) const { Serial.printf("[%lu] [EBP] Cover image is not a JPG, skipping thumbnail\n", millis()); } + // Write an empty bmp file to avoid generation attempts in the future + FsFile thumbBmp; + SdMan.openFileForWrite("EBP", getThumbBmpPath(height), thumbBmp); + thumbBmp.close(); return false; }