Skip to content

Instantly share code, notes, and snippets.

@jaredatch
Created August 5, 2015 14:57
Show Gist options
  • Save jaredatch/fbb4d7e5032a8a2ae538 to your computer and use it in GitHub Desktop.
Save jaredatch/fbb4d7e5032a8a2ae538 to your computer and use it in GitHub Desktop.
Set fallback images for Genesis
<?php
/**
* Set default Genesis images
*
* @since 1.0.0
* @param string $output
* @param array $args
* @return array
*/
function ja_default_genesis_image( $output, $args ) {
global $post;
if ( $output || $args['size'] == 'full' || $args['size'] == 'medium' ) {
return $output;
}
switch( $args['size'] ) {
case 'ja_medium_h' :
$thumbnail = get_bloginfo('stylesheet_directory').'/images/default-image-podcast.jpg';
break;
default :
$thumbnail = get_bloginfo('stylesheet_directory').'/images/default-image.jpg';
break;
}
switch( $args['format'] ) {
case 'html' :
return '<img class="post-image" src="'. $thumbnail. '" alt="'. get_the_title( $post->ID ) .'" />';
case 'url' :
return $thumbnail;
default :
return $output;
}
}
add_filter( 'genesis_get_image', 'ja_default_genesis_image', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment