Skip to content

Commit 3999ac2

Browse files
author
Edwin Westerhoud
committed
Updated some texts to be me more clear about the number of compressions per image.
1 parent 61fc4db commit 3999ac2

5 files changed

Lines changed: 23 additions & 16 deletions

File tree

src/class-tiny-plugin.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,14 @@ public function bulk_compress_page() {
249249
echo '<h2>' . self::translate('Compress JPEG & PNG Images') . '</h2>';
250250
if (empty($_POST['tiny-bulk-compress']) && empty($_REQUEST['ids'])) {
251251
$result = $wpdb->get_results("SELECT COUNT(*) AS `count` FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%' ORDER BY ID DESC", ARRAY_A);
252-
$count = $result[0]['count'];
252+
$image_count = $result[0]['count'];
253+
$sizes_count = count($this->settings->get_active_tinify_sizes());
253254

254255
echo '<p>' . self::translate_escape("Use this tool to compress all images in your media library") . '. ';
255256
echo self::translate_escape("Only images that have not been compressed will be compressed") . '.</p>';
256-
echo '<p>' . sprintf(self::translate_escape("We have found %d images in your media library"), $count) . '. ';
257-
echo self::translate_escape("To begin, just press the button below") . '.</p>';
257+
echo '<p>' . sprintf(self::translate_escape("We have found %d images in your media library and for each image %d sizes will be compressed"), $image_count, $sizes_count) . '. ';
258+
echo sprintf(self::translate_escape('This results in %d compressions at most'), $image_count*$sizes_count) . '.</p>';
259+
echo '<p>' . self::translate_escape("To begin, just press the button below") . '.</p>';
258260

259261
echo '<form method="POST" action="?page=tiny-bulk-compress">';
260262
echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce('tiny-bulk-compress') . '">';

src/class-tiny-settings.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,22 @@ private function render_size_checkbox($size, $option) {
247247

248248
public function render_image_sizes_notice($active_image_sizes_count, $resize_original_enabled) {
249249
echo '<br>';
250+
echo '<p>' . self::translate_escape('Each selected size counts as a compression') . '. ';
251+
250252
if ($resize_original_enabled) {
251253
$active_image_sizes_count++;
252254
}
253255
if ($active_image_sizes_count < 1) {
254-
echo '<p>' . self::translate_escape('With these settings no images will be compressed') . '.</p>';
255-
}
256-
else {
256+
echo self::translate_escape('With these settings no images will be compressed') . '.';
257+
} else {
257258
$free_images_per_month = floor(self::MONTHLY_FREE_COMPRESSIONS / $active_image_sizes_count);
258-
259-
echo '<p>';
260259
echo self::translate_escape('With these settings you can compress');
261260
echo ' <strong>';
262261
printf(self::translate_escape('at least %s images'), $free_images_per_month);
263262
echo '</strong> ';
264263
echo self::translate_escape('for free each month') . '.';
265-
echo '</p>';
266264
}
265+
echo '</p>';
267266
}
268267

269268
public function render_resize() {
348 Bytes
Binary file not shown.

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ msgstr "Als je meer afbeeldingen wilt comprimeren kun je je %s aanpassen"
133133
msgid "Upgrade your %s if you like to compress more images"
134134
msgstr "Upgrade je %s als je meer afbeeldingen wilt comprimeren"
135135

136+
msgid "Each selected size counts as a compression"
137+
msgstr "Elke geselecteerde afmeting telt als een compressie"
138+
136139
msgid "With these settings you can compress"
137140
msgstr "Met deze instellingen kun je elke maand"
138141

@@ -184,8 +187,11 @@ msgstr "Deze tool comprimeert alle afbeeldingen in je media-bibliotheek"
184187
msgid "Only images that have not been compressed will be compressed"
185188
msgstr "Dit geldt alleen voor de afbeeldingen die nog niet zijn gecomprimeerd"
186189

187-
msgid "We have found %d images in your media library"
188-
msgstr "We hebben %d afbeeldingen in de media-bibliotheek gevonden"
190+
msgid "We have found %d images in your media library and for each image %d sizes will be compressed"
191+
msgstr "We hebben %d afbeeldingen in de media-bibliotheek gevonden en voor elke afbeelding worden %d afmetingen gecomprimeerd"
192+
193+
msgid "This results in %d compressions at most"
194+
msgstr "Dit resulteert in een maximaal verbruik van %d compressies"
189195

190196
msgid "To begin, just press the button below"
191197
msgstr "Druk op de knop om te starten"

test/integration/SettingsIntegrationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ public function testShouldPersistNoSizes() {
8989
public function testShouldShowTotalImagesInfo() {
9090
$elements = self::$driver->findElement(WebDriverBy::id('tiny-image-sizes-notice'))->findElements(WebDriverBy::tagName('p'));
9191
$statuses = array_map('innerText', $elements);
92-
$this->assertContains('With these settings you can compress at least 100 images for free each month.', $statuses);
92+
$this->assertContains('Each selected size counts as a compression. With these settings you can compress at least 100 images for free each month.', $statuses);
9393
}
9494

9595
public function testShouldUpdateTotalImagesInfo() {
9696
$element = self::$driver->findElement(
9797
WebDriverBy::xpath('//input[@type="checkbox" and @name="tinypng_sizes[0]" and @checked="checked"]'));
9898
$element->click();
9999
self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(
100-
WebDriverBy::cssSelector('#tiny-image-sizes-notice'), 'With these settings you can compress at least 125 images for free each month.'));
100+
WebDriverBy::cssSelector('#tiny-image-sizes-notice'), 'Each selected size counts as a compression. With these settings you can compress at least 125 images for free each month.'));
101101
// Not really necessary anymore to assert this.
102102
$elements = self::$driver->findElement(WebDriverBy::id('tiny-image-sizes-notice'))->findElements(WebDriverBy::tagName('p'));
103103
$statuses = array_map('innerText', $elements);
104-
$this->assertContains('With these settings you can compress at least 125 images for free each month.', $statuses);
104+
$this->assertContains('Each selected size counts as a compression. With these settings you can compress at least 125 images for free each month.', $statuses);
105105
}
106106

107107
public function testShouldShowCorrectNoImageSizesInfo() {
@@ -111,11 +111,11 @@ public function testShouldShowCorrectNoImageSizesInfo() {
111111
$element->click();
112112
}
113113
self::$driver->wait(2)->until(WebDriverExpectedCondition::textToBePresentInElement(
114-
WebDriverBy::cssSelector('#tiny-image-sizes-notice'), 'With these settings no images will be compressed.'));
114+
WebDriverBy::cssSelector('#tiny-image-sizes-notice'), 'Each selected size counts as a compression. With these settings no images will be compressed.'));
115115
// Not really necessary anymore to assert this.
116116
$elements = self::$driver->findElement(WebDriverBy::id('tiny-image-sizes-notice'))->findElements(WebDriverBy::tagName('p'));
117117
$statuses = array_map('innerText', $elements);
118-
$this->assertContains('With these settings no images will be compressed.', $statuses);
118+
$this->assertContains('Each selected size counts as a compression. With these settings no images will be compressed.', $statuses);
119119
}
120120

121121
public function testShouldShowResizingWhenOriginalEnabled() {

0 commit comments

Comments
 (0)