@@ -822,18 +822,19 @@ function webp_uploads_filter_block_background_images( $block_content, array $blo
822
822
823
823
$ new_url = webp_uploads_get_mime_type_image ( $ attachment_id , $ image_url , $ target_mime );
824
824
825
- if ( is_string ( $ new_url ) ) {
825
+ if ( ! is_string ( $ new_url ) ) {
826
+ continue ;
827
+ }
826
828
827
- $ processor = new WP_HTML_Tag_Processor ( $ block_content );
828
- while ( $ processor ->next_tag () ) {
829
- $ style = $ processor ->get_attribute ( 'style ' );
829
+ $ processor = new WP_HTML_Tag_Processor ( $ block_content );
830
+ while ( $ processor ->next_tag () ) {
831
+ $ style = $ processor ->get_attribute ( 'style ' );
830
832
831
- if ( is_string ( $ style ) && str_contains ( $ style , 'background-image: ' ) && str_contains ( $ style , $ image_url ) ) {
832
- $ updated_style = str_replace ( $ image_url , $ new_url , $ style );
833
- $ processor ->set_attribute ( 'style ' , $ updated_style );
834
- $ block_content = $ processor ->get_updated_html ();
835
- break 2 ;
836
- }
833
+ if ( is_string ( $ style ) && str_contains ( $ style , 'background-image: ' ) && str_contains ( $ style , $ image_url ) ) {
834
+ $ updated_style = str_replace ( $ image_url , $ new_url , $ style );
835
+ $ processor ->set_attribute ( 'style ' , $ updated_style );
836
+ $ block_content = $ processor ->get_updated_html ();
837
+ break 2 ;
837
838
}
838
839
}
839
840
}
0 commit comments