Last active
October 7, 2016 23:15
-
-
Save Phoenix2k/f609dc13f1d3aa71bd55bc25f19d8014 to your computer and use it in GitHub Desktop.
WordPress: Jetpack snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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