Quick Tip: Photon and SSL

VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

JetPack Welcome Screen

JetPack includes a module that offloads the images used on your site to WordPress.com media servers. In most cases, this can take a lot of pressure off of your server, and can also help things load much more quickly than they normally would.

The Photon modules becomes especially useful when used in conjunction with the Tiled Galleries module, which allows you to output fancy galleries on your website in myriad layouts.

However, if you’re running your site over SSL, you may have noticed that Photon doesn’t seem to do anything; in fact, it tends to make things worse. In a normal installation of WordPress, if you insert a standard gallery, you can choose which size of image to use within the Gallery. If you choose to display the “medium” sized image, WordPress will output the medium-sized image in each spot within the Gallery, regardless of how large the original image was.

If you use one of the Tiled Gallery layouts, though, WordPress ignores the Size setting, and, instead, starts out with the original upload, no matter how large it is.

If Photon is working properly, that full-sized image is then sent off to the WordPress.com CDN and dynamically resized (and cropped, if appropriate) and returned in the exact size & shape at which it should be used within the Gallery.

If you’re running your website over SSL, though, the WordPress CDN will reject any images loaded over SSL, and the full-sized upload will be loaded on your page, instead. This can be extremely frustrating if you have a Gallery with 10 or 15 photos, and each of those photos is high-quality (let’s say at least 2048×1536, and an average of 2 megabytes or larger). If you’re loading 10 photos at an average file size of 2 megabytes each, that means, before any other assets or content are included, your page weight is already at 20 megabytes, which is enough to kill many user’s browsers.

There is an extremely simple solution to this issue, though.

The fix is simply to hook into a JetPack filter & instruct it not to reject images loaded over SSL. The code would look something like the following:

add_filter( 'jetpack_photon_reject_https', '__return_false' );

Once you add that code to your theme’s functions.php file, or through some other method that gets it to load on every page of your site, you are ready to start using the JetPack Tiled Galleries and Photon on the secure version of your site.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Quick Tip: Photon and SSL, 5.0 out of 5 based on 1 rating

Leave a Reply