Skip to content

Commit

Permalink
Merge pull request #437 from kiwix/count-webp-media
Browse files Browse the repository at this point in the history
More robust getMediaCount()
  • Loading branch information
kelson42 authored Jan 3, 2021
2 parents 2659f32 + 44c4aa9 commit 18afa97
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

it = counterMap.find("image/gif");
if (it != counterMap.end()) {
counter += it->second;
for (auto &pair:counterMap) {
if (startsWith(pair.first, "image/")) {
counter += pair.second;
}
}

it = counterMap.find("image/png");
if (it != counterMap.end()) {
counter += it->second;
}
return counter;
}

Expand Down

0 comments on commit 18afa97

Please sign in to comment.