0

I have a featured image preview in column view in my Custom Post Types. Now I want to change the size of it. This is my code:

add_filter('manage_posts_columns', 'add_img_column');
add_filter('manage_posts_custom_column', 'manage_img_column', 10, 2);

function add_img_column($columns) {
    $columns['img'] = 'Featured Image';
    return $columns;
}

function manage_img_column($column_name, $post_id) {
    if( $column_name == 'img' ) {
        echo get_the_post_thumbnail($post_id, 'thumbnail');
        return true;
    }
}

And I see it like this:

enter image description here

So know I want to change the size of this image in this view... how... how can I get that? :)

2 Answers 2

0

In functions.php : Make sure featured images are enabled

add_theme_support( 'post-thumbnails' );

then add

add_image_size( 'thumbnail-news', '100', '75', true );

And in the code above change

echo get_the_post_thumbnail($post_id, 'thumbnail');

to

echo get_the_post_thumbnail($post_id, 'thumbnail-news');

2

You can create a new size with the funcion add_image_size, example:

add_image_size('my_new_size', 50, 50, true);

an then when you get the post thumbnail you select this size, like this:

function manage_img_column($column_name, $post_id) {
    if( $column_name == 'img' ) {
        echo get_the_post_thumbnail($post_id, 'my_new_size');
        return true;
    }
}

See the Codex for reference.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.