Home Forums General Issues Use JetPack's Photon CDN for Image fields


Use JetPack's Photon CDN for Image fields

  • Hello,

    I’m curious to see if anyone out there is using Photon CDN and has successfully delivered image ACF fields from the CDN.

    You can pull images from the Photon CDN in your theme like so:

    <?php echo apply_filters( 'jetpack_photon_url', get_template_directory_uri() . '/img/shared/headingImage.jpg' ); ?>

    I’d like to do the same for ACF image fields, any feedback would be appreciated!

  • Hi @thad

    If all that is needed is the filter to be applied to the url, you could use it like so:

    <?php echo apply_filters( 'jetpack_photon_url', get_field('image_field') ); ?>

    This amuses you have the image field setting to return the URL, if you have it set to ID or Object, please refer to the docs to obtain the correct url.


  • Hi!

    Could someone help me out with getting photon working for me. My code for ACF images looks like this:

    <div id="section-2" class="wrapper">
    <div class="wrapper2">
    <?php echo wp_get_attachment_image(get_field('hero_image_2'), 'full', 0, array('class' => 'bilder2')); ?>

    I understand that I need to add
    apply_filters( 'jetpack_photon_url')
    but I’m not really sure how.

    Much appreciate some help!

  • <?php echo apply_filters( 'jetpack_photon_url',wp_get_attachment_image(get_field('hero_image_3'), 'full', 0, array('class' => 'bilder2'))); ?>

    This code shows the site correctly but I’m not sure Photon actually is working? (PageSpeed gives me the same result as the original code)

  • I thought I would share an update on my problem.
    It actually turned out that the Jetpack Photon CDN worked with my original code. However, it broke the responsive image update in WP4.4 – only delivering the original size image.

    I haven’t been able to figure out a way to fix this but looking at the code on my start page (not using the ACF-plugin) it returns the image with a resize “value” and on the pages using ACF it returns with a fit “value”. Don’t know if this has anything to do with it but someone else might have an idea?

    Start page:

    ACF page:

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Use JetPack's Photon CDN for Image fields’ is closed to new replies.