Last active
November 19, 2015 13:31
-
-
Save ewistrand/7bcd296ad5ee2eeaa092 to your computer and use it in GitHub Desktop.
Wordpress Admin Thumbnails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add Thumbnails To Admin & size them to max at 200px | |
*/ | |
add_filter('manage_posts_columns', 'posts_columns', 5); | |
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2); | |
/** | |
* Add CPT Thumbs replace post-type with CPT, not neccesary if post thumbnails are supported for all types | |
*/ | |
add_filter('manage_post-type_posts_columns', 'posts_columns', 5); | |
add_action('manage_post-type_posts_custom_column', 'posts_custom_columns', 5, 2); | |
function posts_columns($defaults){ | |
$defaults['riv_post_thumbs'] = __('Thumbs'); | |
return $defaults; | |
} | |
function posts_custom_columns($column_name, $id){ | |
if($column_name === 'riv_post_thumbs'){ | |
if( has_post_thumbnail() ) { | |
echo the_post_thumbnail('medium'); | |
} else { | |
_e('No Thumbnail For Post'); | |
} | |
echo " | |
<style> | |
.column-riv_post_thumbs img{ | |
max-height: 300px; | |
max-width: 250px; | |
} | |
</style> | |
"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment