Last active
September 24, 2017 21:54
-
-
Save schemapress/9153198ada948aba65bad8865af5c9af to your computer and use it in GitHub Desktop.
Filter to set default image for Schema plugin https://schema.press/
This file contains 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 //* do not include php tag | |
function schema_wp_set_default_image_12345( $json ) { | |
// If image is already defiend, | |
// return our $json array and do not do anything | |
if ( isset($json['media']) && ! empty($json['media']) ) return $json; | |
// There is no image defined in Schema array, | |
// set default ImageObject url, width, and height | |
$json['media']['@type'] = 'ImageObject'; // schema type, do not chage this! | |
$json['media']['url'] = 'http://default-image-url.png'; // set default image url | |
$json['media']['width'] = 720; // set image width | |
$json['media']['height'] = 400; // set image height | |
return $json; | |
} | |
add_filter('schema_json', 'schema_wp_set_default_image_12345'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment