Skip to content

Commit 220ef32

Browse files
committed
feat: Updates function to return null or non-empty strings.
1 parent 95bc6bd commit 220ef32

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plugins/webp-uploads/helper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,12 @@ function webp_uploads_get_mime_type_image( int $attachment_id, string $src, stri
444444
$basename = wp_basename( $metadata['file'] );
445445

446446
if ( $src_basename === $basename ) {
447-
return str_replace(
447+
$result = str_replace(
448448
$basename,
449449
$metadata['sources'][ $mime ]['file'],
450450
$src
451451
);
452+
return '' === $result ? null : $result;
452453
}
453454
}
454455

@@ -471,11 +472,12 @@ function webp_uploads_get_mime_type_image( int $attachment_id, string $src, stri
471472
continue;
472473
}
473474

474-
return str_replace(
475+
$result = str_replace(
475476
$size_data['file'],
476477
$size_data['sources'][ $mime ]['file'],
477478
$src
478479
);
480+
return '' === $result ? null : $result;
479481
}
480482
}
481483

0 commit comments

Comments
 (0)