If you want to add a default thumbnail for each of the thumbnail sizes specified in your theme, look for the following code in your theme’s functions.php file.
add_image_size('Sidebar Featured', 210, 80, TRUE); add_image_size('Sidebar', 60, 60, TRUE); add_image_size('Footer Featured', 198, 140, TRUE);
The above code reflects 3 of the image sizes added to the Poise Child Theme (which I plan on releasing soon), used for example purposes. The above code may look different depending on the number and size of the images added to your particular theme.
For the Poise Child Theme, the code below would add 4 default thumbnails.
default-thumbnail-sidebar.png (210×80 pixels)
default-thumbnail-mini-square.png (60×60 pixels)
default-thumbnail-footer.png (198×140 pixels)
default-thumbnail.png (150x150px) // This is the default size created by WordPress
You will need to create 4 image files with the appropriate name and dimensions and upload them to your child theme images folder.
/** * Add Image Sizes * * @author Jen Baumann * @link https://dreamwhisperdesigns.com/?p=429 */ add_image_size('Sidebar Featured', 210, 80, TRUE); add_image_size('Sidebar', 60, 60, TRUE); add_image_size('Footer Featured', 198, 140, TRUE); add_filter('genesis_get_image', 'dream_default_images', 10, 2); /** * Add Default Images * * @author Jen Baumann * @link https://dreamwhisperdesigns.com/?p=429 */ function dream_default_images($output, $args) { global $post; if ( $output || $args['size'] == 'full' || $args['size'] == 'medium' ) return $output; switch( $args['size'] ) { case 'Sidebar Featured' : // Create file. Must be 210x80 pixels $thumbnail = get_bloginfo('stylesheet_directory').'/images/default-thumbnail-sidebar.png'; break; case 'Sidebar' : // Create file. Must be 60x60 pixels $thumbnail = get_bloginfo('stylesheet_directory').'/images/default-thumbnail-mini-square.png'; break; case 'Footer Featured' : // Create file. Must be 198x140 pixels $thumbnail = get_bloginfo('stylesheet_directory').'/images/default-thumbnail-footer.png'; break; default : // Create file. Must be 150x150 pixels $thumbnail = get_bloginfo('stylesheet_directory').'/images/default-thumbnail.png'; break; } switch( $args['format'] ) { case 'html' : return '<img class="blogalign post-image" src="'.$thumbnail.'" alt="'. get_the_title($post->ID) .'" />'; case 'url' : return $thumbnail; default : return $output; } }
You should add this anywhere after this line: require_once(TEMPLATEPATH.'/lib/init.php');
but before the final ?>
tag at the end of the file.
Lastly, add the following to your theme’s stylesheet
img.blogalign { float: left; display: inline; } .home img.blogalign { float: none; }
If you want to set default thumbnails for specific categories, you can use this code.
add_filter( 'genesis_get_image', 'dream_default_category_images' ); /** * Default Category Images * * @author Jen Baumann * @link https://dreamwhisperdesigns.com/?p=429 */ function dream_default_category_images($output) { if ( $output ) { if ( in_category('ID') ) { $output = '<img alt="category-name-1" class="alignleft post-image" src="'.get_bloginfo('stylesheet_directory').'/images/category-name-1.png">'; } elseif ( in_category('ID') ) { $output = '<img alt="category-name-2" class="alignleft post-image" src="'.get_bloginfo('stylesheet_directory').'/images/category-name-2.png">'; } } return $output; }
And, the bare-bones simple version:
/** * Default Image * * @author Jen Baumann * @link https://dreamwhisperdesigns.com/?p=429 */ add_filter('genesis_get_image', 'dream_default_image', 10, 2); function dream_default_image($output, $args) { global $post; if( $output || $args['size'] == 'full' ) return $output; $thumbnail = CHILD_URL.'/images/thumb.png'; switch($args['format']) { case 'html' : return '<img src="'.$thumbnail.'" class="alignleft post-image" alt="'. get_the_title($post->ID) .'" />'; break; case 'url' : return $thumbnail; break; default : return $output; break; } }