2017-09-03 102 views

回答

0

好吧,我能想到的解決這個問題得到的唯一方法是檢查broswer和服務於一個.WEBP圖像如果瀏覽器通過與.WEBP

$postId = $post->ID; 
$patterns = array("/.jpg/", "/.jpeg/", "/.png/"); 
$thePostThumbUrl = get_the_post_thumbnail_url($postId, array(768,768)); 
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') || strpos($_SERVER['HTTP_USER_AGENT'], 'OPR/') || strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') && !strpos($_SERVER['HTTP_USER_AGENT'], 'Edge')) 
    $thePostThumbUrl = preg_replace($patterns, ".webp", $thePostThumbUrl); 
替換文件擴展支持它