Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use the 'medium' image size for a Tasty Recipe card when it exists.
<?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
You can’t perform that action at this time.