@@ -123,6 +123,12 @@ function cimo_get_media_type_label( $mimetype ) {
123123 $ optimization_savings = number_format ( 100 * ( $ original_filesize - $ converted_filesize ) / $ original_filesize , 2 );
124124 }
125125
126+ // If optimization savings is not a valid number or is negative, do not display it
127+ if ( ! is_numeric ( $ optimization_savings ) || floatval ( $ optimization_savings ) < 0 ) {
128+ echo '<p> ' . esc_html__ ( 'Cimo did not optimize this attachment. ' , 'cimo-image-optimizer ' ) . '</p> ' ;
129+ return ;
130+ }
131+
126132 $ kb_saved = cimo_format_filesize ( $ original_filesize - $ converted_filesize , 1 , true );
127133 $ optimization_savings_class = ( $ optimization_savings > 0 ) ? 'cimo-optimization-savings-up ' : 'cimo-optimization-savings-down ' ;
128134
@@ -132,6 +138,7 @@ function cimo_get_media_type_label( $mimetype ) {
132138 $ converted_format_raw = isset ( $ cimo ['convertedFormat ' ] ) ? $ cimo ['convertedFormat ' ] : ( isset ( $ post ->post_mime_type ) ? $ post ->post_mime_type : '' );
133139 $ converted_format = $ converted_format_raw ? cimo_convert_mimetype_to_format ( $ converted_format_raw ) : '' ;
134140 $ media_type_label = cimo_get_media_type_label ( $ converted_format_raw );
141+ $ is_image_media = is_string ( $ converted_format_raw ) && strpos ( strtolower ( $ converted_format_raw ), 'image/ ' ) === 0 ;
135142 $ converttime = isset ( $ cimo ['conversionTime ' ] ) ? floatval ( $ cimo ['conversionTime ' ] ) : null ;
136143 if ( $ converttime !== null ) {
137144 if ( $ converttime < 1000 ) {
@@ -207,7 +214,9 @@ function cimo_get_media_type_label( $mimetype ) {
207214 echo '<li class="cimo-bulk-optimization-number"> ' ;
208215 echo '🏞️ ' . sprintf (
209216 /* translators: %s: bulk optimization count */
210- esc_html__ ( '%s thumbnail(s) processed ' , 'cimo-image-optimizer ' ),
217+ $ is_image_media
218+ ? esc_html__ ( '%s thumbnail(s) processed ' , 'cimo-image-optimizer ' )
219+ : esc_html__ ( '%s file(s) processed ' , 'cimo-image-optimizer ' ),
211220 '<span class="cimo-value"> ' . esc_html ( $ bulk_optimization_count ) . '</span> '
212221 );
213222 echo '</li> ' ;
0 commit comments