我有很多image/webp
图片,想在Safari浏览器中使用回退的image/jpg
图片。
出于某种原因,Chrome(以及其他所有浏览器)仍然使用jpg图像而不是webp。
<picture>
<source class="content_image" height="150" width="150" src="<?php echo get_stylesheet_directory_uri();?>/assets/pictures/section/logo_dsv_150x150.webp" type="image/webp">
<source class="content_image" height="150" width="150" src="<?php echo get_stylesheet_directory_uri();?>/assets/pictures/section/logo_dsv_150x150.png" type="image/png">
<img height="150" width="150" src="<?php echo get_stylesheet_directory_uri();?>/assets/pictures/section/logo_dsv_150x150.png" alt="lorem ipsum">
</picture>
我也将其与ACF结合使用:
<?php
$image_02_jpg = get_field('content_picture_02_jpg');
$image_02_webp = get_field('content_picture_02_webp');
?>
<picture>
<source class="content_image" width="679" height="450px" src="<?php echo $image_02_webp['url']; ?>" type="image/webp">
<source class="content_image" width="679" height="450px" src="<?php echo $image_02_jpg['url']; ?>" type="image/jpeg">
<img class="content_image" width="679" height="450px" src="<?php echo $image_02_jpg['url']; ?>" alt="content_image">
</picture>