Generate empty thumbnail for books without a cover

This commit is contained in:
CaptainFrito 2026-01-26 10:42:19 +07:00
parent 5d8178cf9d
commit 10f8ff8b22

View File

@ -435,11 +435,8 @@ bool Epub::generateThumbBmp(int height) const {
const auto coverImageHref = bookMetadataCache->coreMetadata.coverItemHref; const auto coverImageHref = bookMetadataCache->coreMetadata.coverItemHref;
if (coverImageHref.empty()) { if (coverImageHref.empty()) {
Serial.printf("[%lu] [EBP] No known cover image for thumbnail\n", millis()); Serial.printf("[%lu] [EBP] No known cover image for thumbnail\n", millis());
return false; } else if (coverImageHref.substr(coverImageHref.length() - 4) == ".jpg" ||
} coverImageHref.substr(coverImageHref.length() - 5) == ".jpeg") {
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()); Serial.printf("[%lu] [EBP] Generating thumb BMP from JPG cover image\n", millis());
const auto coverJpgTempPath = getCachePath() + "/.cover.jpg"; 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()); 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; return false;
} }