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
Download the patch
Attached to this post is the fix for this problem. It’s a patch file for Jetpack version 1.7.
- 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