Check how your theme displays the featured image. Mine was using the get_the_image() function which doesn’t support photon. wp_get_attachment_image_src() also appears not to work. Either use a different one, or do what I did and pass the URL through a custom function:
// return photon server to use based on url
function static_counter( $url ) {
srand( crc32( basename( $url ) ) );
$static_counter = rand( 0, 2 );
srand(); // this resets everything that relies on this, like array_rand() and shuffle()
return $static_counter;
}
// fetch photon equivalent url
function photon_url($url) {
if (strpos($url,'http://') !== false)
{
$url=str_replace('http://','',$url);
}
return "http://i".static_counter($url).".wp.com/".$url;
}
My theme is using the_post_thumbnail to fetch the featured image.
Any suggestions how I could solve this?
I used the code by macgamer
// return photon server to use based on url
function static_counter( $url ) {
srand( crc32( basename( $url ) ) );
$static_counter = rand( 0, 2 );
srand(); // this resets everything that relies on this, like array_rand() and shuffle()
return $static_counter;
}
// fetch photon equivalent url
function photon_url($url) {
if (strpos($url,'http://') !== false)
{
$url=str_replace('http://','',$url);
}
return "http://i".static_counter($url).".wp.com/".$url;
}
and I replaced the_post_thumbnail(); with
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID)); // get thumbnail image url
$photon_featured_image = photon_url($featured_image[0]);
echo "<img src='".$photon_featured_image."' class='wp-post-image'> ";