WordPress.org

Ready to get started?Download WordPress

Forums

Jetpack by WordPress.com
[resolved] Jetpack Photon and Custom field images (4 posts)

  1. Raoul
    Member
    Posted 1 year ago #

    On my blog i display my images (featured images) trough a custom field, is there any way to use the Jetpack Photon CDN with my custom field?

    Regards~

    http://wordpress.org/extend/plugins/jetpack/

  2. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    You should be able to edit your theme to make sure the images are called via Photon when it's activated. You can follow the instructions here to do so:
    http://jetpack.me/2013/07/11/photon-and-themes/

  3. Raoul
    Member
    Posted 1 year ago #

    Yes, but i don't know how to implement with my shortcode, custom field, to display the images through the Photon CDN. All images from my site are displayed by this
    Shortcode:
    <?php myabp_print_thumbnail(85, 85); ?>
    85, 85 = width, height

    Custom field:
    mabp_thumbnail_url
    my site is jocurihd.com

    Like this?

    if( function_exists( 'jetpack_photon_url' ) ) {
        add_filter( 'jetpack_photon_url', 'mabp_thumbnail_url', 10, 3 );
    }
  4. Jeremy Herve
    Happiness Engineer
    Plugin Author

    Posted 1 year ago #

    You should start by adding the following to your theme's functions.php file:

    if( function_exists( 'jetpack_photon_url' ) ) {
        add_filter( 'jetpack_photon_url', 'jetpack_photon_url', 10, 3 );
    }

    Then, locate the function that is creating the image tag from the Custom Field value. It will include something like this:

    get_post_meta($post->ID, 'mabp_thumbnail_url', true)

    Now, you will need to add jetpack_photon_url and the size in there, like so:

    $args = array(
        'resize' => '85,85',
    );
    $image_url = jetpack_photon_url( get_post_meta($post->ID, 'mabp_thumbnail_url', true), $args );

    $image_url might have a different name, so this will depend on your theme. But the idea is to wrap get_post_meta into the jetpack_photon_url function, and to add the image size there.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic