You need the attachment ID – which is the same as the “thumbnail ID” – not the post ID. It’s confusing. Maybe by WP 5.0 they’ll update the nomenclature!
So, I think this’ll work:
function attached_image_content( $column_name, $post_ID ) {
if ( $column_name == 'foobar' ) {
//Change the image size from default 'thumbnail' here
$post_attached_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );
if ( $post_attached_image ) {
//as you probably know, the url is the first array value
echo '<img style="width:100%;" src="' . $post_attached_image[0] . '" />';
}
}
}
add_action( 'manage_cpt_posts_custom_column', 'attached_image_content', 10, 2 );
Related Posts:
- How do I remove dashboard access from specific user roles?
- How to Change the Default Home Page for the WordPress Dashboard?
- 3.3: How do you hide the new dashboard welcome panel?
- How can we customize the logo and some text on the welcome screen?
- Can I set a default dashboard layout for all users?
- Appearance->Editor not visible
- Which hook for processing plugin page form data?
- How to solve 500 Error on WordPress Admin Dashboard due to time-out on getdirsize
- How to get view count of every page on site and add that (increasing) number to Dashboard Widget
- Dashboard menu missing
- Can’t access dashboard as administrator, login as any other level works though
- Attachment display settings only allows “full-size”
- Continuous Login Sessions For Super Admins Across Multi-Site Network of Sites
- Add attachment for all images in post
- Modifying the built-in behavior of ajax tag type-ahead functionality of WordPress
- Grabbing the first image attached to a post and use it with the admin columns
- How to activate the dashboard
- Backend Checkboxes working – but not visual?
- Set Link Target Checkbox chcked on Edit Image MOdal Window in Admin Post Edit Screen?
- Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
- Top toolbar is not showing in wordpress admin panel
- Want to know who is login Admin/User
- Dashboard RSS Widget Overhaul
- Extending the user profile [closed]
- HTML Img with data:image src gets sanitized in admin?
- How To Create WordPress Dashboard Item
- Adding a WordPress Admin Dashboard to my local wordpress site
- Sortable admin columns by 0.00 number
- WordPress4.1.15 Dashboard links not working
- Unable to render Admin Notices
- My code for creating an admin option doesn’t work
- WordPress gallery image link gives 404 when not logged in
- WP Logs me out after updating anything on dashboard
- TinyMCE buttons broken
- WordPress admin panel is blank
- What are the standard admin CSS id/class tags?
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Admin Ajax is returning 0
- How To Retrieve An Image Attachment’s Alt Text?
- Add custom column to Users admin panel
- How to get image title/alt attribute?
- wp_verify_nonce vs check_admin_referer
- Add a Separator to the Admin Menu?
- How to determine whether we are in add New page/post/CPT or in edit page/post/CPT in wordpress admin?
- how to know if admin is in edit page or post [duplicate]
- Programmatically adding images to media library
- Modal window from within WordPress admin
- Where in WP can I check history or log of updates of plugins etc?
- Adding a custom admin page
- Creating an Image-Centric Custom Post Type?
- How does admin-ajax.php work?
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- Programmatically get images by URL and save in uploads folder
- how to get original image using wp_get_attachment_image_src
- How to remove entire admin menu?
- Can I attach image to post without adding it to post?
- Get the first image from post content (eg.: hotlinked images)
- How can I speed up my WP admin section?
- How to pass parameters to admin_notices?
- Admin: very slow edit page caused by core meta query
- if admin is logged in
- Search posts by ID in admin
- Setting admin edit panels & metaboxes positions and visibility for ALL users and admins
- Find out which moderator approved comment?
- The website cannot display the page
- How To Remove WordPress Version From The Admin Footer
- Sort pages in loop by admin’s page attributes order field?
- Remove Dimension from wp_get_attachment_image
- Edit “thank you for creating with WordPress” in version 3.3.1
- Hide other users’ posts in admin panel
- Set Default Admin Colour For All Users
- Editor Styles and Typekit
- WordPress admin stylesheet
- This CSS Stuffing Works, But Is This A Good Practice?
- Is it possible to create a WordPress tour? V3.3.1
- Securing Admin Accounts – Username Discovery
- getting attachement images src and add classes
- is_admin() returns true when using admin-ajax.php from front end script
- remove links from images using functions.php
- How to save dismissable notice state in WP 4.2?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- How do I optimize a custom post type admin page with 25,000 posts?
- Settings API – adding setting fields dynamically?
- Disable Media Uploads to non Admin Users
- How do I load a CSS style into WordPress admin area only?
- Allowing admin-ajax.php to receive “application/json” instead of “x-www-form-urlencoded”
- Can an admin check passwords of registered users?
- How can I target WordPress 3.8 new interface MP6 with CSS?
- Notification that the admin is online
- Does wordpress create activity, update logs?
- sort child pages on admin
- How-to make the admin area mobile friendly [closed]
- Disable image attachment links
- wp_get_attachment_image_src and server path
- How to remove list view from media library?
- How to disable the “Your site has updated to WordPress x.y.z” admin email?
- Load plugin scripts and styles only on plugin page
- Plugin to remove Admin menu items based on user role?
- How to obtain the user ID of the current profile being edited in WP-Admin?
- Check if post has attachments (not image)