Skip to content

Commit ef86440

Browse files
committed
Fix picture element support for post thumbnail
1 parent a6dbbca commit ef86440

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

plugins/webp-uploads/hooks.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,9 @@ function webp_uploads_img_tag_update_mime_type( string $original_image, string $
673673
* @return string The updated HTML markup.
674674
*/
675675
function webp_uploads_update_featured_image( string $html, int $post_id, int $attachment_id ): string {
676+
if ( webp_uploads_is_picture_element_enabled() ) {
677+
return webp_uploads_wrap_image_in_picture( $html, 'post_thumbnail_html', $attachment_id );
678+
}
676679
return webp_uploads_img_tag_update_mime_type( $html, 'post_thumbnail_html', $attachment_id );
677680
}
678681
add_filter( 'post_thumbnail_html', 'webp_uploads_update_featured_image', 10, 3 );

plugins/webp-uploads/picture-element.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @return string The new image tag.
2020
*/
2121
function webp_uploads_wrap_image_in_picture( string $image, string $context, int $attachment_id ): string {
22-
if ( 'the_content' !== $context ) {
22+
if ( ! in_array( $context, array( 'the_content', 'post_thumbnail_html', 'widget_block_content' ), true ) ) {
2323
return $image;
2424
}
2525

0 commit comments

Comments
 (0)