Skip to content

Instantly share code, notes, and snippets.

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 danielbachhuber/9a127a90c0721df3bae18e935a996676 to your computer and use it in GitHub Desktop.
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.
<?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