| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | * @since 1.0 |
| 8 | 8 | * @since 1.9 Function signature changed. |
| 9 | 9 | * @author Jonathan Buttigieg |
| 10 | 10 | * |
| 11 | - * @param ProcessInterface $process The optimization process object. | |
| 11 | + * @param \Imagify\Optimization\Process\ProcessInterface $process The optimization process object. | |
| 12 | 12 | * @return string The output to print. |
| 13 | 13 | */ |
| 14 | 14 | function get_imagify_attachment_optimization_text( $process ) { |
| 15 | 15 | if ( ! $process->is_valid() ) { |
| @@ -99,8 +99,24 @@ | ||
| 99 | 99 | if ( $process->has_next_gen() ) { |
| 100 | 100 | $has_nextgen = $process->is_full_next_gen() ? __( 'Yes', 'imagify' ) : __( 'Partially', 'imagify' ); |
| 101 | 101 | } |
| 102 | 102 | $output .= $output_before . '<span class="data">' . __( 'Next-Gen generated:', 'imagify' ) . '</span> <strong class="big">' . esc_html( $has_nextgen ) . '</strong>' . $output_after; |
| 103 | + | |
| 104 | + // When the API permanently refused the conversion, show the reason it gave. | |
| 105 | + $nextgen_reason = ''; | |
| 106 | + | |
| 107 | + if ( ! empty( $optimized_data['sizes'] ) && is_array( $optimized_data['sizes'] ) ) { | |
| 108 | + foreach ( $optimized_data['sizes'] as $size_data ) { | |
| 109 | + if ( ! empty( $size_data['permanent_error'] ) && ! empty( $size_data['error'] ) ) { | |
| 110 | + $nextgen_reason = $size_data['error']; | |
| 111 | + break; | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | + | |
| 116 | + if ( $nextgen_reason ) { | |
| 117 | + $output .= $output_before . '<span class="data">' . __( 'Next-Gen status:', 'imagify' ) . '</span> <strong>' . esc_html( $nextgen_reason ) . '</strong>' . $output_after; | |
| 118 | + } | |
| 103 | 119 | |
| 104 | 120 | $total_optimized_thumbnails = $data->get_optimized_sizes_count(); |
| 105 | 121 | |
| 106 | 122 | if ( $total_optimized_thumbnails ) { |