3200creative
9/5/2014 - 1:09 AM

Define a default featured image / post thumbnail for archive in wordpress - Genesis Framework

Define a default featured image / post thumbnail for archive in wordpress - Genesis Framework

/** Define a default post thumbnail */
add_filter('genesis_get_image', 'default_image_fallback', 10, 2);
function default_image_fallback($output, $args) {
    global $post;
    if( $output || $args['size'] == 'full' )
        return $output;

    $thumbnail = CHILD_URL.'/images/default.png';

    switch($args['format']) {

        case 'html' :
            return '<img src="'.$thumbnail.'" class="attachment-'. $args['size'] .'" alt="'. get_the_title($post->ID) .'" />';
            break;
        case 'url' :
            return $thumbnail;
            break;
       default :
           return $output;
            break;
    }
}