Skip to content

Commit bddf80b

Browse files
committed
Docs: Update return type
1 parent 220ef32 commit bddf80b

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

plugins/webp-uploads/helper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,10 @@ function webp_uploads_should_generate_all_fallback_sizes(): bool {
432432
*
433433
* @since 2.2.0
434434
*
435-
* @param int $attachment_id The ID of the attachment.
436-
* @param string $src The original image src url.
437-
* @param string $mime A mime type we are looking to get image url.
438-
* @return string|null Returns mime type image if available.
435+
* @param int $attachment_id The ID of the attachment.
436+
* @param string $src The original image src url.
437+
* @param string $mime A mime type we are looking to get image url.
438+
* @return non-empty-string|null Returns mime type image if available.
439439
*/
440440
function webp_uploads_get_mime_type_image( int $attachment_id, string $src, string $mime ): ?string {
441441
$metadata = wp_get_attachment_metadata( $attachment_id );

plugins/webp-uploads/hooks.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -822,18 +822,19 @@ function webp_uploads_filter_block_background_images( $block_content, array $blo
822822

823823
$new_url = webp_uploads_get_mime_type_image( $attachment_id, $image_url, $target_mime );
824824

825-
if ( is_string( $new_url ) ) {
825+
if ( ! is_string( $new_url ) ) {
826+
continue;
827+
}
826828

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' );
830832

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;
837838
}
838839
}
839840
}

0 commit comments

Comments
 (0)