Created
March 8, 2019 17:54
-
-
Save danielbachhuber/9a127a90c0721df3bae18e935a996676 to your computer and use it in GitHub Desktop.
Use the 'medium' image size for a Tasty Recipe card when it exists.
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 | |
/** | |
* Use the 'medium' image size for a Tasty Recipe card when it exists. | |
* | |
* @param array $template_vars Template variables to be used. | |
* @param object $recipe Recipe object. | |
*/ | |
add_filter( 'tasty_recipes_recipe_template_vars', function( $template_vars, $recipe ) { | |
$recipe_json = $recipe->to_json(); | |
if ( ! empty( $recipe_json['image_sizes']['medium'] ) ) { | |
$template_vars['recipe_image'] = $recipe_json['image_sizes']['medium']['html']; | |
} | |
return $template_vars; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment