diff --git a/include/book.h b/include/book.h index 7dc1ed8c5..5d049ad6c 100644 --- a/include/book.h +++ b/include/book.h @@ -59,6 +59,8 @@ class Book mutable std::string data; }; + typedef std::vector> Illustrations; + public: // functions Book(); ~Book(); @@ -95,6 +97,8 @@ class Book const std::string& getFaviconUrl() const; const std::string& getFaviconMimeType() const; + Illustrations getIllustrations() const; + const std::string& getDownloadId() const { return m_downloadId; } void setReadOnly(bool readOnly) { m_readOnly = readOnly; } @@ -142,7 +146,7 @@ class Book uint64_t m_mediaCount = 0; bool m_readOnly = false; uint64_t m_size = 0; - std::vector> m_illustrations; + Illustrations m_illustrations; // Used as the return value of getDefaultIllustration() when no default // illustration is found in the book diff --git a/src/book.cpp b/src/book.cpp index de82c6fbc..bf7c3e18f 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -47,6 +47,11 @@ Book::~Book() { } +Book::Illustrations Book::getIllustrations() const +{ + return m_illustrations; +} + bool Book::update(const kiwix::Book& other) { if (m_readOnly) diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index 6897b3142..7d463f714 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -58,10 +58,10 @@ IllustrationInfo getBookIllustrationInfo(const Book& book) { kainjow::mustache::list illustrations; if ( book.isPathValid() ) { - for ( auto illustration_size : zim::Archive(book.getPath()).getIllustrationSizes() ) { + for ( const auto& illustration : book.getIllustrations() ) { illustrations.push_back(kainjow::mustache::object{ - {"icon_width", to_string(illustration_size)}, - {"icon_height", to_string(illustration_size)}, + {"icon_width", to_string(illustration->width)}, + {"icon_height", to_string(illustration->height)}, {"icon_scale", "1"}, }); }