• I noticed on my AMP homepage that all the featured images were broken. Found out the WebP-Express function in features.php is pointing to the wrong directory. It should be http$1/wp-content/webp-express/webp-images/doc-root/wordpress/wp-content

    Wordpress is missing from the directory path.

    function ampforwp_webp_express_compatibility($content){
    	if(function_exists('webp_express_process_post')){
    		preg_match_all('/src="(.*?)"/', $content,$src);
    		if(isset($src[1][0])){
    			$img_url = esc_url($src[1][0]);
    			if(!preg_match('/\.webp/', $img_url)){
    				$config = \WebPExpress\Config::loadConfigAndFix();
    				if($config['destination-folder'] == 'mingled'){
    					$img_url_webp = $img_url;
    				}else{
    					$img_url_webp = preg_replace('/http(.*?)\/wp-content(.*?)/', 'http$1/wp-content/webp-express/webp-images$2', $img_url);
    					if($config['destination-structure'] == 'doc-root'){
    						$img_url_webp = preg_replace('/http(.*?)\/wp-content(.*?)/', 'http$1/wp-content/webp-express/webp-images/doc-root/wp-content$2', $img_url);
    					}
    				}
    				if(!preg_match('/\.webp/', $img_url)){	
    					$img_url_webp = esc_url($img_url_webp).".webp";
    			 		$content = str_replace($img_url, $img_url_webp, $content); 
    				}
    			}
    	 	}
    	}	
    	return $content;
    }
    • This topic was modified 2 years, 3 months ago by IceDarkness.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WebP-Express Issue’ is closed to new replies.