Photon is an image acceleration and modification service for Jetpack-connected WordPress sites. Converted images are cached automatically and served from the WordPress.com CDN. Images can be cropped, resized, and filtered by using a simple API controlled by GET query arguments. When Photon is enabled in Jetpack, images are updated on the fly.

We want to create the best image manipulation and acceleration service in the world for WordPress users. Photon is only allowed to be used by sites hosted on WordPress.com, or on Jetpack-connected WordPress sites. If you move to another platform, or disconnect Jetpack from your site, please also switch to another magic image service. We can’t promise it will continue to work if you stop using WordPress or Jetpack. Abuse of Jetpack or violation of the WordPress.com Terms of Service could result in suspension of your site from WordPress.com-connected services.

Basic URL

http://i0.wp.com/$REMOTE_IMAGE_URL

Features

  • Open source! Available via SVN at http://code.svn.wordpress.org/photon/ and on Trac at http://code.trac.wordpress.org/browser/photon
  • Fast! Photon utilizes multiple levels of caching, including a globally distributed CDN to make sure images are served as fast as possible.
  • All images are compressed on the fly using either a combination of pngquant and OptiPNG or jpegoptim. Lossless compression is available by specifying a quality setting of 100 in the query arguments.
  • Multiple domains. In order to take advantage of parallel downloads we support multiple sub-domains for Photon. If you tend to have many images per page you can split them across i0.wp.com, i1.wp.com, and i2.wp.com. To take use of caching, it can be useful to use the same sub-domain for files in subsequent calls.
  • SSL support. You can use Photon on SSL pages without mixed content warnings. Just use https://i{0,1,2}.wp.com instead of http://i{0,1,2}.wp.com

Supported query arguments

Parameter Description Usage
w width (defaults to px, supports %) w=50
h height (defaults to px, supports %) h=50
crop crop x,y,w,h (defaults to %) crop=5,10,20,40
resize resize and crop to given dimensions (px) resize=250,300
fit keep aspect ratio, but fit to within given box (px) fit=100,100
lb add letterboxing, color code is optional (it’s black by default) lb=300,250,1A4E9F
ulb remove letterboxing (auto detects the letterbox color) ulb
filter apply various imagefilter() filters filter=grayscale
brightness adjusts brightness brightness=100
contrast adjusts contrast contrast=50
colorize applies a color hue colorize=255,0,0
smooth smoothes out the image smooth=2
zoom size images for high pixel ratio devices zoom=2
quality sets the quality for JPEG images quality=50
strip removes metadata from JPEG images strip=all

Also see the Photon API page for more detailed explanations and examples.

Example plugin developer checks

  • To determine if Jetpack is installed and can generate photon URLs:
    function_exists( ‘jetpack_photon_url' )
  • To determine whether Photon is an active Jetpack module:
    class_exists( 'Jetpack' ) && method_exists( 'Jetpack', 'get_active_modules' ) && in_array( 'photon', Jetpack::get_active_modules() )

Limitations

  • No cache invalidations – currently the images are cached “forever”. If you want to “refresh” an image you will need to change the name of the image. Adding random query arguments, commonly known as cachebusters, will not work.
  • 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.
  • We will “upscale” an image in some circumstances. However if your original image is smaller than the upscale limit and you request to make it larger than the upscale limit, we will serve you the original unaltered image (Note: 2000px is the upscale limit for all images except GIFs, which is 1000px). Upscaled images are usually of poor quality and we want to avoid sending large pixelated images.
  • Some animated gifs break if resized or transformed via Photon.
  • The zoom parameter is clamped between 1 and 10 and above 3 it is also limited to increments of 0.5.
  • Photon will not fetch and process images larger than 55 Megabytes.

Terms of Service

  • Use of this service is for users of the Jetpack by WordPress.com plugin only, and may be used by sites hosted on WordPress.com, or on Jetpack-connected WordPress sites. If you move to another platform, or disconnect Jetpack from your site, we can’t promise it will continue to work.
  • Abuse of the Jetpack by WordPress.com Terms of Service could result in suspension of your site from WordPress.com-connected services. By enabling Photon you agree to be responsible in what you publish; in particular be sure that you don’t use the service for prohibited items (things like spam, viruses, or hate content). WordPress.com reserves the right, in its sole discretion, to temporarily or permanently revoke your ability to use and access Photon, with or without notice.