@@ -147,7 +147,7 @@ public function compress_image() {
147147 $ result ['thumbnail ' ] = $ tiny_metadata ->get_url ('thumbnail ' );
148148 echo json_encode ($ result );
149149 } else {
150- echo $ this ->render_media_column ( self :: MEDIA_COLUMN , $ id );
150+ echo $ this ->render_compress_details ( $ tiny_metadata );
151151 }
152152
153153 exit ();
@@ -176,28 +176,31 @@ public function add_media_columns($columns) {
176176
177177 public function render_media_column ($ column , $ id ) {
178178 if ($ column === self ::MEDIA_COLUMN ) {
179- $ tiny_metadata = new Tiny_Metadata ($ id );
180- $ missing = $ tiny_metadata ->get_missing_sizes ($ this ->settings ->get_tinify_sizes ());
181- $ success = count ($ tiny_metadata ->get_success_sizes ());
182- $ total = count ($ missing ) + $ success ;
179+ $ this ->render_compress_details (new Tiny_Metadata ($ id ));
180+ }
181+ }
182+
183+ private function render_compress_details ($ tiny_metadata ) {
184+ $ missing = $ tiny_metadata ->get_missing_sizes ($ this ->settings ->get_tinify_sizes ());
185+ $ success = count ($ tiny_metadata ->get_success_sizes ());
186+ $ total = count ($ missing ) + $ success ;
183187
184- if (count ($ missing ) > 0 ) {
185- printf (self ::translate_escape ('Compressed %d out of %d sizes ' ), $ success , $ total );
188+ if (count ($ missing ) > 0 ) {
189+ printf (self ::translate_escape ('Compressed %d out of %d sizes ' ), $ success , $ total );
190+ echo '<br/> ' ;
191+ if (($ error = $ tiny_metadata ->get_latest_error ())) {
192+ echo '<span class="error"> ' . self ::translate_escape ('Latest error ' ) . ': ' . self ::translate_escape ($ error ) .'</span><br/> ' ;
193+ }
194+ echo '<button type="button" class="tiny-compress" data-id=" ' . $ tiny_metadata ->get_id () . '"> ' .
195+ self ::translate_escape ('Compress ' ) . '</button> ' ;
196+ echo '<div class="spinner hidden"></div> ' ;
197+ } else {
198+ printf (self ::translate_escape ('Compressed %d out of %d sizes ' ), $ success , $ total );
199+ $ savings = $ tiny_metadata ->get_savings ();
200+ if ($ savings ['count ' ] > 0 ) {
186201 echo '<br/> ' ;
187- if (($ error = $ tiny_metadata ->get_latest_error ())) {
188- echo '<span class="error"> ' . self ::translate_escape ('Latest error ' ) . ': ' . self ::translate_escape ($ error ) .'</span><br/> ' ;
189- }
190- echo '<button type="button" class="tiny-compress" data-id=" ' . $ id . '"> ' .
191- self ::translate_escape ('Compress ' ) . '</button> ' ;
192- echo '<div class="spinner hidden"></div> ' ;
193- } else {
194- printf (self ::translate_escape ('Compressed %d out of %d sizes ' ), $ success , $ total );
195- $ savings = $ tiny_metadata ->get_savings ();
196- if ($ savings ['count ' ] > 0 ) {
197- echo '<br/> ' ;
198- echo self ::translate_escape ('Total size ' ) . ': ' . size_format ($ savings ['input ' ]) . '<br/> ' ;
199- echo self ::translate_escape ('Compressed size ' ) . ': ' . size_format ($ savings ['output ' ]);
200- }
202+ echo self ::translate_escape ('Total size ' ) . ': ' . size_format ($ savings ['input ' ]) . '<br/> ' ;
203+ echo self ::translate_escape ('Compressed size ' ) . ': ' . size_format ($ savings ['output ' ]);
201204 }
202205 }
203206 }
0 commit comments