Skip to content

Instantly share code, notes, and snippets.

@Phoenix2k
Last active October 7, 2016 23:15
Show Gist options
  • Save Phoenix2k/f609dc13f1d3aa71bd55bc25f19d8014 to your computer and use it in GitHub Desktop.
Save Phoenix2k/f609dc13f1d3aa71bd55bc25f19d8014 to your computer and use it in GitHub Desktop.
WordPress: Jetpack snippets
<?php
/**
* Override Jetpack Open Graph sharing image
*
* @link https://jetpack.com/tag/open-graph/
*/
add_filter( 'jetpack_images_get_images', 'override_jetpack_images_get_images', 20, 3 );
function override_jetpack_images_get_images( $media, $post_id, $args ) {
$root_directory = get_bloginfo( 'stylesheet_directory' );
$image_path = '/img/social-share.jpg';
$permalink = get_permalink( $post_id );
$image_url = apply_filters( 'jetpack_photon_url', $root_directory . $image_path );
return array( array(
'type' => 'image',
'from' => 'custom_fallback',
'src' => esc_url( $image_url ),
'href' => $permalink,
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment