Skip to content

Instantly share code, notes, and snippets.

@ericakfranz
Created April 19, 2015 23:00
Show Gist options
  • Save ericakfranz/56c9964f5eebda8352ba to your computer and use it in GitHub Desktop.
Save ericakfranz/56c9964f5eebda8352ba to your computer and use it in GitHub Desktop.
Filter WP SEO's OpenGraph and Twitter image meta tags
<?php
/**
* Return 'medium' image for mobile devices since that is what we're
* loading to display as the featured image on each post.
*/
//* Filter WP SEO's OpenGraph image output
add_filter('wpseo_opengraph_image_size', 'disi_opengraph_image_size');
function disi_opengraph_image_size($val) {
if( wp_is_mobile() ) {
return 'medium';
} else {
return 'large';
}
}
//* Filter WP SEO's Twitter Card image output
add_filter( 'wpseo_twitter_image_size', 'disi_custom_twitter_image_size');
function disi_custom_twitter_image_size( $img_size ) {
if( wp_is_mobile() ) {
return 'medium';
} else {
return 'large';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment