Skip to content

Commit b65588f

Browse files
author
Jacob Middag
committed
Show total size
1 parent 428d50e commit b65588f

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

src/class-tiny-metadata.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,20 @@ public function get_latest_error() {
7676
}
7777
return $message;
7878
}
79+
80+
public function get_savings() {
81+
$result = array(
82+
'input' => 0,
83+
'output' => 0,
84+
'count' => 0
85+
);
86+
foreach ($this->values as $key => $details) {
87+
if (isset($details['input']) && isset($details['output'])) {
88+
$result['count']++;
89+
$result['input'] += $details['input']['size'];
90+
$result['output'] += $details['output']['size'];
91+
}
92+
}
93+
return $result;
94+
}
7995
}

src/class-tiny-plugin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ public function render_media_column($column, $id) {
175175
echo '<div class="spinner"></div>';
176176
} else {
177177
printf(self::translate_escape('Compressed %d out of %d sizes'), $success, $total);
178-
$details = $tiny_metadata->get_value();
179-
if ($details && isset($details['input'])) {
178+
$savings = $tiny_metadata->get_savings();
179+
if ($savings['count'] > 0) {
180180
echo '<br/>';
181-
echo self::translate_escape('Original size') . ': ' . size_format($details['input']['size']) . '<br/>';
182-
echo self::translate_escape('Compressed size') . ': ' . size_format($details['output']['size']);
181+
echo self::translate_escape('Total size') . ': ' . size_format($savings['input']) . '<br/>';
182+
echo self::translate_escape('Compressed size') . ': ' . size_format($savings['output']);
183183
}
184184
}
185185
}
-592 Bytes
Binary file not shown.

src/languages/tiny-compress-images-nl_NL.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ msgstr "Comprimeer alle ongecomprimeerde afmetingen"
4040
msgid "Compressed %d out of %d sizes"
4141
msgstr "%d van de %d afmetingen zijn gecomprimeerd"
4242

43-
msgid "Original size"
44-
msgstr "Oorspronkelijke grootte"
43+
msgid "Total size"
44+
msgstr "Totale grootte"
4545

4646
msgid "Compressed size"
4747
msgstr "Gecomprimeerde grootte"

0 commit comments

Comments
 (0)