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
- Where in WP can I check history or log of updates of plugins etc?
- How does admin-ajax.php work?
- Is it possible to create a WordPress tour? V3.3.1
- Securing Admin Accounts – Username Discovery
- Can an admin check passwords of registered users?
- How to find attachment by it’s name?
- Prevent author from changing their posts if admin has modified
- Set Featured Image programmatically (in admin) with JavaScript?
- Making the thumbnails in the backend Media section bigger
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Customize the upload screen
- How to print the output of the get_num_queries function from frontend to backend?
- Javascript not working in admin
- Custom Dashboard Home Screen Options
- Downloading entire site locally with httrack
- query attachments of parent page if attachments of current page are smaller than …
- add_submenu_page set for multiple roles [duplicate]
- How To Create User Specific Admin User Pages?
- Adding markup to column text in “Edit Pages” admin page
- Change code to display image attachment page
- Why can I not view image attachment pages?
- Disable HTML (Text) Tab in Post Editor
- Add image attachment to post via coding?
- Removing width and height attributes from wp-get-attachment
- Change home-url in dashboard
- Image popup in a lightbox / overlay from the backend 3.5 admin area (plugin)
- How to restrict the editors from viewing/editing pages created by admin?
- Admin multiple column sorting
- How do I add a contact form?
- Unable to login, old site with previous developer gone
- How can I show the contents of only a few users
- WordPress Remove Submenus
- using rewrites to secure login page
- Redirect from the dashboard to edit.php if wp_is_mobile() is true
- Seems that admin_post_{action} does not executing
- If statement for admin page
- Customizing WordPress Admin – How to Change the Avatar size
- Create a WordPress administrator without access to back-end
- How To Make Iris Color Picker Showed Up Over Form and Text?
- Post Gallery list attachments except the one used as post thumbnail
- my checkbox is not saving it’s value
- Can’t login to my admin area
- How much traffic is real traffic?
- How to change the descriptive text on the menus admin page?
- Getting rid of menu items on a custom taxonomy
- Parsing post->ID in included plugin file
- changing the default picture size link url
- Gutenberg UI has changed
- Call require_once form admin page with checkbox
- Custom image size not displaying with wp_get_attachment_image()
- How To Remove Import/Export Option From Tools?
- How to create custom backend admin menu in different languages?
- Highlight active Admin Menu when added though add_menu_page
- Delete attached images from posts
- Error “Sorry, you are not allowed to access this page”
- Create WordPress Menu Item Without Linking to a Custom Page
- Search Only Works when Logged into Admin
- Different role for free and pro users in wordpress without using bbpress
- Hide Image Container if No Image Attachments
- Enqueue script throws error in console
- Adding additional text fields and image upload to a Page?
- Calculate and save an average in a meta
- How to fix: Clicking ‘Quick Edit’ link in Admin (edit.php) makes posts disappear?
- Use the wordpress admin table
- Modify ‘the_content’ appearance in the admin area