Skip to content

Instantly share code, notes, and snippets.

@smeric
Created October 11, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smeric/63a7cbc10a4bb94586c15d3c9b44cc55 to your computer and use it in GitHub Desktop.
Save smeric/63a7cbc10a4bb94586c15d3c9b44cc55 to your computer and use it in GitHub Desktop.
Overwrite Yoast SEO Facebook & Twitter sharing images declaration with a custom one.
<?php
/**
* Std image size for social sharing.
**/
add_action( 'after_setup_theme', 'mytheme_setup_theme' );
function mytheme_setup_theme() {
add_image_size( 'social-800x420', 800, 420, true );
}
/**
* Replace default sizes with std one.
**/
add_filter( 'wpseo_opengraph_image_size', 'mytheme_social_image_size' );
add_filter( 'wpseo_twitter_image_size', 'mytheme_social_image_size' );
function mytheme_social_image_size($val) {
return 'social-800x420';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment