This simple slideshow demonstrates a problem with the JetPack stats plugin which results in a broken image when viewing the site using Chrome. A fix for the problem is provided for Jetpack v1.7
Links:
Admin-bar Stats image not showing up
Chrome browser does not show images generated by HTTP handler
Download the patch
Attached to this post is the fix for this problem. It’s a patch file for Jetpack version 1.7.
Explanation
- When the webpage is created Jetpack sets the source for the image in the admin bar as “http://example.com/wp-admin/admin.php?page=stats&noheader&proxy&chart=admin-bar-hours&height=20&hours=48″
- The browser performs a GET for this image
- Which sends the message to WordPress admin which invokes the JetPack stats function called stats_reports_page().
- This then sends a remote request to wordpress.com
- Which replies with the generated PNG file in the body of the response
- The Stats function then echo’ed this PNG file to the browser using the following (simplified) code
header( "Content-Type: image/png" );
die( $get['body'] )
- Apparently Google chrome doesn’t care for this ( see the second link )
- It is happier when the code is changed to
header( "Content-Type: image/png" );
$img = $get['body'];
header( 'Content-Length: ' . strlen( $img ) );
echo $img;
exit();
- So that’s what the patch file contains
Thanks, great searvice dude! i am on it now to fix it.
guy, please explain pls wehere to replace the code! you wrote it it for higher level geeks, pls make it understandable like me newbie.
Hi Toufiq, the simplest solution is to upgrade JetPack. The problem has already been fixed.
See http://wordpress.org/support/topic/plugin-jetpack-admin-bar-stats-image-not-showing-up?replies=11