PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / 3.8.0
TinyPNG – JPEG, PNG & WebP image compression v3.8.0
3.8.0 3.7.0 3.6.14 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.7.0 1.7.1 1.7.2 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.0.0 3.0.1 3.1.0 3.2.0 3.2.1 3.3 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.10 3.6.11 3.6.12 3.6.13 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
tiny-compress-images / src / views / compress-details.php
tiny-compress-images / src / views Last commit date
account-status-connected.php 2 months ago account-status-create-advanced.php 2 months ago account-status-create-simple.php 2 months ago account-status-loading.php 4 years ago bulk-optimization-form.php 7 months ago bulk-optimization-upgrade-notice.php 2 months ago bulk-optimization.php 2 months ago compress-details-processing.php 2 months ago compress-details.php 2 months ago dashboard-widget.php 2 months ago notice-feedback.php 2 months ago optimization-chart.php 2 months ago request-review.php 4 months ago settings-conversion-delivery.php 4 months ago settings-conversion-enabled.php 4 months ago settings-conversion-output.php 4 months ago settings-conversion.php 4 months ago settings-diagnostics.php 7 months ago settings-original-image-original.php 4 months ago settings-original-image-preserve.php 4 months ago settings-original-image.php 1 week ago settings.php 4 months ago
compress-details.php
263 lines
1 <?php
2 /**
3 * Compression details on media overview page.
4 *
5 * @var Tiny_Plugin $this The plugin instance.
6 * @var Tiny_Image $tiny_image The image being compressed.
7 * @var int[] $images_to_compress The IDs that are being compressed
8 */
9
10 $available_sizes = array_keys( $this->settings->get_sizes() );
11 $conversion_enabled = $this->settings->get_conversion_enabled();
12 $active_sizes = $this->settings->get_sizes();
13 $active_tinify_sizes = $this->settings->get_active_tinify_sizes();
14 $error = $tiny_image->get_latest_error();
15 $total = $tiny_image->get_count( array( 'modified', 'missing', 'has_been_compressed', 'compressed', 'has_been_converted' ) );
16 $active = $tiny_image->get_count( array( 'uncompressed', 'never_compressed', 'unconverted' ), $active_tinify_sizes );
17 $image_statistics = $tiny_image->get_statistics( $active_sizes, $active_tinify_sizes );
18 $available_uncompressed_sizes = $image_statistics['available_uncompressed_sizes'];
19 $size_before = $image_statistics['initial_total_size'];
20 $size_after = $image_statistics['compressed_total_size'];
21
22 $size_active = array_fill_keys( $active_tinify_sizes, true );
23 $size_exists = array_fill_keys( $available_sizes, true );
24 ksort( $size_exists );
25
26 ?>
27 <div class="details-container">
28 <div class="details">
29 <?php
30 if ( $error ) {
31 // dashicons-warning available for WP 4.3+
32 ?>
33 <span class="icon dashicons dashicons-no error"></span>
34 <?php } elseif ( $total['missing'] > 0 || $total['modified'] > 0 ) { ?>
35 <span class="icon dashicons dashicons-yes alert"></span>
36 <?php } elseif ( $total['compressed'] > 0 && $available_uncompressed_sizes > 0 ) { ?>
37 <span class="icon dashicons dashicons-yes alert"></span>
38 <?php } elseif ( $total['compressed'] > 0 ) { ?>
39 <span class="icon dashicons dashicons-yes success"></span>
40 <?php } ?>
41 <span class="icon spinner hidden"></span>
42 <?php if ( $total['has_been_compressed'] > 0 || ( 0 == $total['has_been_compressed'] && 0 == $available_uncompressed_sizes ) ) { ?>
43 <span class="message">
44 <?php
45 printf(
46 wp_kses(
47 /* translators: %d: number of compressed sizes */
48 _n( '<strong>%d</strong> size compressed', '<strong>%d</strong> sizes compressed', $total['has_been_compressed'], 'tiny-compress-images' ),
49 array(
50 'strong' => array(),
51 )
52 ),
53 absint( $total['has_been_compressed'] )
54 );
55 ?>
56 </span>
57 <br>
58 <?php } ?>
59 <?php if ( $active['uncompressed'] > 0 ) { ?>
60 <span class="message">
61 <?php
62 /* translators: %d: number of sizes to be compressed */
63 printf( esc_html( _n( '%d size to be compressed', '%d sizes to be compressed', $available_uncompressed_sizes, 'tiny-compress-images' ) ), absint( $available_uncompressed_sizes ) );
64 ?>
65 </span>
66 <br>
67 <?php } ?>
68 <?php
69 if ( $conversion_enabled ) {
70 if ( $total['has_been_converted'] > 0 || 0 == $image_statistics['available_unconverted_sizes'] ) {
71 ?>
72 <span class="message">
73 <?php
74 printf(
75 wp_kses(
76 /* translators: %d: number of compressed sizes */
77 _n( '<strong>%d</strong> size converted', '<strong>%d</strong> sizes converted', $total['has_been_converted'], 'tiny-compress-images' ),
78 array(
79 'strong' => array(),
80 )
81 ),
82 absint( $total['has_been_converted'] )
83 );
84 ?>
85 </span>
86 <br>
87 <?php } ?>
88 <?php if ( $active['unconverted'] > 0 ) { ?>
89 <span class="message">
90 <?php
91 /* translators: %d: number of sizes to be converted */
92 printf( esc_html( _n( '%d size to be converted', '%d sizes to be converted', $active['unconverted'], 'tiny-compress-images' ) ), absint( $active['unconverted'] ) );
93 ?>
94 </span>
95 <br>
96 <?php
97 }
98 }
99 ?>
100 <?php if ( $size_before - $size_after ) { ?>
101 <span class="message">
102 <?php
103 /* translators: %.0f%: savings percentage */
104 printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), ( 1 - floatval( $size_after ) / floatval( $size_before ) ) * 100 );
105 ?>
106 </span>
107 <br>
108 <?php } ?>
109 <?php if ( $error ) { ?>
110 <span class="message error_message">
111 <?php echo esc_html__( 'Latest error', 'tiny-compress-images' ) . ': ' . esc_html( $error ); ?>
112 </span>
113 <br>
114 <?php } ?>
115 <a class="thickbox message" href="#TB_inline?width=700&amp;height=500&amp;inlineId=modal_<?php echo absint( $tiny_image->get_id() ); ?>">
116 <?php esc_html_e( 'Details', 'tiny-compress-images' ); ?>
117 </a>
118 </div>
119 <?php if ( $available_uncompressed_sizes > 0 ) { ?>
120 <?php if ( in_array( $tiny_image->get_id(), $images_to_compress, true ) ) { ?>
121 <span class="hidden auto-compress"></span>
122 <?php } ?>
123 <button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo absint( $tiny_image->get_id() ); ?>">
124 <?php esc_html_e( 'Compress', 'tiny-compress-images' ); ?>
125 </button>
126 <button type="button" class="tiny-mark-as-compressed button button-small button-secondary" data-id="<?php echo absint( $tiny_image->get_id() ); ?>">
127 <?php esc_html_e( 'Mark as Compressed', 'tiny-compress-images' ); ?>
128 </button>
129 <?php } elseif ( $active['unconverted'] > 0 && $tiny_image->can_be_converted() ) { ?>
130 <button type="button" class="tiny-compress button button-small button-primary" data-id="<?php echo absint( $tiny_image->get_id() ); ?>">
131 <?php esc_html_e( 'Convert', 'tiny-compress-images' ); ?>
132 </button>
133 <button type="button" class="tiny-mark-as-compressed button button-small button-secondary" data-id="<?php echo absint( $tiny_image->get_id() ); ?>">
134 <?php esc_html_e( 'Mark as Converted', 'tiny-compress-images' ); ?>
135 </button>
136 <?php } ?>
137 </div>
138
139 <div class="modal" id="modal_<?php echo absint( $tiny_image->get_id() ); ?>">
140 <div class="tiny-compression-details">
141 <h3>
142 <?php
143 /* translators: %s is the image filename */
144 printf( esc_html__( 'Compression details for %s', 'tiny-compress-images' ), esc_html( $tiny_image->get_name() ) );
145 ?>
146 </h3>
147 <table>
148 <tr>
149 <th><?php esc_html_e( 'Size', 'tiny-compress-images' ); ?></th>
150 <th><?php esc_html_e( 'Initial Size', 'tiny-compress-images' ); ?></th>
151 <th><?php esc_html_e( 'Compressed', 'tiny-compress-images' ); ?></th>
152 <th><?php esc_html_e( 'Format', 'tiny-compress-images' ); ?></th>
153 <?php
154 if ( $conversion_enabled ) {
155 ?>
156 <th><?php esc_html_e( 'Converted', 'tiny-compress-images' ); ?></th> <?php } ?>
157 <th><?php esc_html_e( 'Date', 'tiny-compress-images' ); ?></th>
158 </tr>
159 <?php
160 $i = 0;
161 $sizes = $tiny_image->get_image_sizes() + $size_exists;
162 foreach ( $sizes as $size_name => $size ) {
163 if ( ! is_object( $size ) ) {
164 $size = new Tiny_Image_Size();
165 }
166 ?>
167 <tr class="<?php echo ( 0 == $i % 2 ) ? 'even' : 'odd'; ?>">
168 <?php
169 echo '<td>';
170 echo '<span title="' . esc_html( basename( (string) $size->filename ) ) . '">';
171 echo ( Tiny_Image::is_original( $size_name ) ? esc_html__( 'Original', 'tiny-compress-images' ) : esc_html( ucfirst( rtrim( $size_name, '_wr2x' ) ) ) );
172 echo ' </span>';
173 if ( ! array_key_exists( $size_name, $active_sizes ) && ! Tiny_Image::is_retina( $size_name ) ) {
174 echo '<em>' . esc_html__( '(not in use)', 'tiny-compress-images' ) . '</em>';
175 } elseif ( $size->missing() && ( Tiny_Settings::wr2x_active() || ! Tiny_Image::is_retina( $size_name ) ) ) {
176 echo '<em>' . esc_html__( '(file removed)', 'tiny-compress-images' ) . '</em>';
177 } elseif ( $size->modified() ) {
178 echo '<em>' . esc_html__( '(modified after compression)', 'tiny-compress-images' ) . '</em>';
179 } elseif ( Tiny_Image::is_retina( $size_name ) ) {
180 echo '<em>' . esc_html__( '(WP Retina 2x)', 'tiny-compress-images' ) . '</em>';
181 } elseif ( $size->resized() ) {
182 /* translators: %1$dx%2$d: resized image width x height */
183 printf( '<em>' . esc_html__( '(resized to %1$dx%2$d)', 'tiny-compress-images' ) . '</em>', absint( $size->meta['output']['width'] ), absint( $size->meta['output']['height'] ) );
184 }
185 echo '</td>';
186
187 if ( $size->is_duplicate() ) {
188 echo '<td>-</td>';
189 /* translators: %s: name of similar thumbnail size */
190 printf( '<td colspan=4><em>' . esc_html__( 'Same file as "%s"', 'tiny-compress-images' ) . '</em></td>', esc_html( ucfirst( $size->duplicate_of_size() ) ) );
191 } elseif ( $size->has_been_compressed() ) {
192
193 echo '<td>' . esc_html( size_format( $size->meta['input']['size'], 1 ) ) . '</td>';
194 echo '<td>' . esc_html( size_format( $size->meta['output']['size'], 1 ) ) . '</td>';
195 echo '<td>' . esc_html( $size->meta['output']['type'] ) . '</td>';
196 if ( $conversion_enabled ) {
197 echo '<td>' . esc_html( $size->conversion_text() ) . '</td>';
198 }
199 /* translators: %s human friendly time difference */
200 echo '<td>' . sprintf( esc_html__( '%s ago', 'tiny-compress-images' ), esc_html( human_time_diff( $size->end_time( $size_name ) ) ) ) . '</td>';
201 } elseif ( ! $size->exists() ) {
202 echo '<td>-</td>';
203 echo '<td colspan=4><em>' . esc_html__( 'Not present', 'tiny-compress-images' ) . '</em></td>';
204 } elseif ( isset( $size_active[ $size_name ] ) || Tiny_Image::is_retina( $size_name ) ) {
205 echo '<td>' . esc_html( size_format( $size->filesize(), 1 ) ) . '</td>';
206 echo '<td colspan=5><em>' . esc_html__( 'Not compressed', 'tiny-compress-images' ) . '</em></td>';
207 } elseif ( isset( $size_exists[ $size_name ] ) ) {
208 echo '<td>' . esc_html( size_format( $size->filesize(), 1 ) ) . '</td>';
209 echo '<td colspan=4><em>' . esc_html__( 'Not configured to be compressed', 'tiny-compress-images' ) . '</em></td>';
210 } elseif ( ! array_key_exists( $size_name, $active_sizes ) ) {
211 echo '<td>' . esc_html( size_format( $size->filesize(), 1 ) ) . '</td>';
212 echo '<td colspan=4><em>' . esc_html__( 'Size is not in use', 'tiny-compress-images' ) . '</em></td>';
213 } else {
214 echo '<td>' . esc_html( size_format( $size->filesize(), 1 ) ) . '</td>';
215 echo '<td>-</td>';
216 echo '<td>-</td>';
217 echo '<td>-</td>';
218 echo '<td>-</td>';
219 }
220 ?>
221 </tr>
222 <?php
223 ++$i;
224 } // End foreach().
225 if ( $image_statistics['image_sizes_compressed'] > 0 ) {
226 ?>
227 <tfoot>
228 <tr>
229 <td><?php esc_html_e( 'Combined', 'tiny-compress-images' ); ?></td>
230 <td><?php echo esc_html( size_format( $size_before, 1 ) ); ?></td>
231 <td><?php echo esc_html( size_format( $size_after, 1 ) ); ?></td>
232 <td></td>
233 <?php
234 if ( $conversion_enabled ) {
235 ?>
236 <td></td> <?php } ?>
237 <td></td>
238 </tr>
239 </tfoot>
240 <?php
241 }
242 ?>
243 </table>
244 <p>
245 <strong>
246 <?php
247 if ( $size_before - $size_after ) {
248 printf(
249 /* translators: %1$.0f%%: savings percentage, %2$s: total file size savings */
250 esc_html__( 'Total savings %1$.0f%% (%2$s)', 'tiny-compress-images' ),
251 ( 1 - floatval( $size_after ) / floatval( $size_before ) ) * 100,
252 esc_html( size_format( $size_before - $size_after, 1 ) )
253 );
254 } else {
255 /* translators: %.0f%%: savings percentage */
256 printf( esc_html__( 'Total savings %.0f%%', 'tiny-compress-images' ), 0 );
257 }
258 ?>
259 </strong>
260 </p>
261 </div>
262 </div>
263