Photon troubles

It’s a bit ironic that on the web site I have set up for – among other things – testing purposes, I have a seemingly unresolvable issue with Jetpack’s Photon.

So what is Photon?

To quote the official documentation, “Photon is an image acceleration and editing service for sites hosted on WordPress.com or on Jetpack-connected WordPress sites. That means less load on your host and faster images for your readers.

So how does this really work? Enabling Photon will allow Jetpack to copy and distribute your images on wordpress.com servers around the world and serve them to the viewer’s browser from those servers instead of your hosting service provide3r’s actual server. This will speed up your site because:

  • WordPress.com servers are likely faster than your host’s server
  • WordPress.com servers are distributed around the world, so your images will be served from a server closest to the request, which will allow for greater download speeds
  • Photon will store your images in several sizes and send the appropriate image for each request; ie if the request is for an 400x400px image, Photon will take care to serve the actual 400x400px image instead of a larger image which would unnecessarily slow down the download

And the best part is that all you have to do to use it is click one simple button..!

The Photon activation button

Is it really worth it?

Is the resulting speed-up really worth the one-click trouble? If you want an in-depth analysis, check out this great article by Dave Warfel on this subject. If you just want a short answer, for sites that serve multiple images per page or post, it’s definitely worth a shot.

Are there any pitfalls to this approach? Well, an obvious one is that your images will get copied – multiple times – to some servers where you have no control over them, or your copyright. If this worries you, see what Robin Cornett says on this subject in his Think twice about using Photon article, and decide for yourself if the risk is worth it.

For me personally, on this site, the concerns about copyright and image distribution issues are non-existent, so I sure do want to use Photon. Additional points are that it’s there with Jetpack anyway, and it’s Free, so – why not?

Also, the annoying “Must be enabled to use tiled galleries” notion leans me in the “hell yeah” direction: I hate crowding my sites with superfluous plug-ins, and I’d really love to use the one I already have installed to get as much as possible done.

So what’s the problem

Because apparently something doesn’t work. By enabling Photon, all of my images on this web site get broken and don’t display at all. What the Hell!??! Now, while pretty neat, Photon really isn’t necessary, so I could resolve this issue just by turning it off – but #1 – I don’t like such easy solutions, and #2 – I have found that resolving such issues often results in a broad learning experience. So let us dig in!

By studying the official documentation, in the Limitations section I have stumbled upon this little bit of information:

  • We only fetch, resize, and serve gif, png, and jpg images from servers that listen on port 80 for HTTP and port 443 for HTTPS. This is about 99.99% of the web servers in the world. If you are having issues, please try using this filter.

So, it figures my server would be in the 0.01%, right?Overall, it’s likely an SSL issue since I’m on a free-hosted web service and I didn’t really bother with the SSL certificates on this site.

So the documentation says I should add a bit of code, somewhere, somehow. Since the referenced bit of code seems to be an action, I checked out the How to use actions and filters article in Jetpack documentation and used the Code snippets plugin to apply the bit of code.

The bit of code that made sense to add was

apply_filters ( 'jetpack_photon_reject_https', true );

since the documentation claims the function defaults to “false” and yeah, it seems it does. However, this gave no results so I tried the less logical,

apply_filters ( 'jetpack_photon_reject_https', false);

solution. Sadly, so far none of them worked or caused any changes.

Why did you use a code snippets plugin?

Essentially, it’s important to not edit any code in WordPress you didn’t write yourself. If you modify any original code you are risking breaking your site due to one of the following scenarios:

  • the theme or the plug-in could get updated and your code could get erased
  • the theme or the plug-in could get updated and your code could cause some kind of a conflict
  • your could decide to change the theme while forgetting which modifications you made, where, and why and your site would get broken

This is why it’s important to always use child themes in order to modify themes; create your own plug-ins if you need to modify plug-ins, or use a code snippets plug-in for minor modifications.

The cool links I stumbled on along the way

The Beginner’s Guide to WordPress Actions and Filters

Leave a Reply

Your email address will not be published. Required fields are marked *