Yes, you can do it programmatically and it probably can be built with some of the Related Questions listed here on the right of the page.
But, IMO, this is faster and easier to do with a plugin.
Advanced Custom Fields
Create an image field and associate it with your Custom Post Type.
That results in:
Another good plugin capable of doing the same
Custom Content Type Manager
A nice feature is the “Repeatable Field”, which is a premium add-on in ACF.
Reference Q&A: Creating Photo Gallery System with Custom Post Type
Related Posts:
- How to disable generation of default image sizes for some custom post types?
- Add metabox with media uploader in a custom post type [duplicate]
- Remove tabs from media uploader for a CPT
- Removing Image Sizes for Custom Post Type
- Image size filtering in Media uploader according to custom post type
- wp is not defined error using wp.media to create a custom image uploader
- How to rename image at uploading on specific plugin or post-type in WordPress
- window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes
- Duplicate Custom Header Functionality into the post edit screen
- Get image post ID in media upload
- WordPress 3.5 Media Uploader – Only allow 1 upload and certain file types
- frontend image post uploader
- Checking if $_FILE isset for an array of file upload metaboxes
- How to add multiple images to a custom post type without plugin [closed]
- Create a custom post type for a photo post
- link featured image to external link
- Invalid file type when using wp_upload_bits to upload PDF to a custom post type
- Multi Photo Upload with Caption on Front End for Custom Post Type
- Allow authors to create article image
- Why is my select meta data not saving?
- Link to full size post thumbnail
- Add Standard Page Attributes Metabox for Page Parent
- Hide editor while keeping add media button in custom post type
- dynamically add a custom field or metabox to custom post type [duplicate]
- Add a button or image button that calls wp functions in the wp-admin
- Custom Post Type with image gallery
- Make metabox of custom post type fully autosave- and bulk-/quick-edit compatible
- Multiple featured sizes / images / excerpts
- How can i add thumbnails images to particular post (using code not admin pannel) in wordpress
- Custom Post Type uses Custom Tags in add_filter?
- Post Quote with image on header for news site
- Custom date changer post_date => future – missed schedule error
- How to store multiple values in 1 meta_key with radio input?
- What is the best way to correlate one-to-many content-type relationships?
- Is it possible to create relational metabox values in a custom post?
- Changing custom type name hides the posts
- Add custom image size for custom post type or taxonomy
- Visual editor issue by having multiple tiny mce editors in a CPT
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- A better way to add a meta box to custom post types
- How to get the upcoming post ID from front end?
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- How to automatically set ‘default image size’ for specific Custom Post Type
- Plugin – Combine Meta Box Input Fields into single saveble record
- Getting Custom Post Type Meta on Publish
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Custom Post Type Video – Online/Offline
- Grouping metadatas into one
- Anon function and add_meta_box
- Metabox not show in categories custom post type cmb2
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Display correctly using metabox.io
- Create Connection Between two post types
- Problem: wp_query outputs all images on site
- pre_get_posts for custom page builder meta box
- Disable closing on metaboxes
- Show Custom Post Type meta boxes only on Page Edit
- Cannot save CPT meta box
- How to make custom taxonomy into drop down select in a custom metabox
- Adding Page Templates to post but it ignored it
- Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
- Problems with image size on the server WordPress
- Create a Dropdown from Custom Post Type
- Translating custom post type metaboxes [closed]
- Adding a metabox on a CPT’s submenu page
- How to update post meta on uploaded image from a custom form?
- Fixed values for same post translations
- How to Add multiple instance of meta box to custom post type
- Using POST method in meta box, no results
- meta box on custom post type
- Adding custom image sizes and post types to a plugin or to a theme?
- Ordering values entered in Custom Taxonomies
- Listing custom terms in custom post meta
- Permalinks: custom structure for taxonomy – tags?
- Custom Post Type & Meta Box – Displaying meta box information on front end?
- How can I move (or create another) publish button?
- Wrap meta boxes & data handling for specific post types in classes?
- How to: wordpress job listing and candidates details
- How to handle large number of images in a post?
- Can custom fields be added without a meta box?
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Meta Box on Custom Post Type not saving
- How do you get the full size url of an attachment image
- Custom “radio button meta box” not saving correctly
- Global custom meta box
- Sizing textarea field in custom metabox
- Redirect to another page using contact form 7? [closed]
- Moving meta boxes in admin
- Meta Data for Custom Post Type not saving
- Remove “show sharing buttons” metabox Jetpack from custom post type
- Add additional field to custom post_type
- Meta-Boxes for CustomPostType cause PHP Errors and Notices in “Add New” view
- Custom Post Meta from custom metaboxes is randomly being deleted
- custom post type metaboxes not saving
- Add a custom meta box for client to order CPT posts how they want
- Why won’t this jQuery code work?
- How can i link a custom post type thumbnail to intermediate size
- Save Multiple Metabox values