From 95b32b168d088088faeb9f8725b2369c1d22a6e0 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Fri, 1 Jan 2021 17:05:32 +0100 Subject: [PATCH] More robust getMediaCount() --- src/reader.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index db756f7b9..67838de89 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -120,20 +120,12 @@ unsigned int Reader::getMediaCount() const = this->parseCounterMetadata(); unsigned int counter = 0; - auto it = counterMap.find("image/jpeg"); - if (it != counterMap.end()) { - counter += it->second; + for (auto it = counterMap.begin(); it != counterMap.end(); ++it) { + if (it->first.rfind("image/", 0) == 0) { + counter += it->second; + } } - it = counterMap.find("image/gif"); - if (it != counterMap.end()) { - counter += it->second; - } - - it = counterMap.find("image/png"); - if (it != counterMap.end()) { - counter += it->second; - } return counter; }