patric-boehner
8/5/2015 - 2:57 PM

Set fallback images for Genesis

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 );