wp_get_attachment_image_srcset is the key here:
wp_get_attachment_image_srcset( int $attachment_id, array|string $size="medium", array $image_meta = null )
I believe the missing information you lack, is that post thumbnails are actually an attachment ID. In combination with get_post_thumbnail_id you should be able to generate srcset values.
But also keep in mind that while googling, every question I found was asking how to remove srcset not add. Apparently what you wanted was actually added in WP 4.4. The answer might actually be to not set srcset at all, and let WP set it for you.
Related Posts:
- How do I disable responsive images in WP 4.4?
- WP 4.4. responsive images browser choosing the “wrong” one
- How to insert pictures without hard coded dimensions?
- Making WordPress Gallery (.gallery-item) Responsive?
- WP 4.4 aspect ratio with responsive image
- How can I serve different images depending on screen size with wordpress
- How to Make WordPress Default gallery responsive on mobile?
- Responsive background images added inline
- Responsive Images – Add srcset attributes to custom Images Function
- Get a list of all image sizes that match aspect ratio of original one
- How to exclude an image size from the WordPress srcset
- Responsive Images Resizing Images
- Featured image (responsive) above content is too small after update to WordPress 4.4
- How to display a different image size for mobile
- WP Responsive images – upload custom image sizes
- Fuzzy Images in WordPress 4.4
- Removing height and width from images with a caption
- AJAX – save an $_FILES picture in media library
- How to create ‘Local’ filters for WordPress srcset sizes in template parts?
- Get image URL after image created from canvas and sent to WP uploads with AJAX
- Multiple amp-image overlays. How to properly do this in wordpress?
- How can I use cached images in an AJAX response?
- Fallback for missing srcset images
- max_srcset_image_width doesn’t work as intended
- Using SRCSET with Images and Featured Images
- Help to upload post attachments from Ajax
- How to implement secure frontend image upload? [closed]
- Understanding WordPress image sizes and responsive images
- Custom responsive ‘featured image’ sizes
- One of my image sizes isn’t showing up in srcset
- How to stop WordPress from completely overriding my tags in my templates?
- the_content not showing responsive image attributes srcset or sizes
- Serve different images per screen size and cache possible?
- Disable Media File Image Link On Mobile Devices
- All 3?: Responsive resizing of images + image width of actual image for small images + max-width for all larger images
- Why does WordPress list all image sizes in srcset even if they’re larger?
- Responsive header image
- What’s are some best practices for responsive images (e.g. for section headers)?
- WordPress Responsive Image ( srcset ) not work properly
- Responsive Images – Defining
- Decide how Hero image appears on mobile
- Responsive Featured Images Not Working
- Responsive images with srcset
- Getting extra image links in code with wp_get_attachment_image
- built-in responsive images in content – do I need to add anything to functions.php?
- Responsive images in Bootstrap 4 slider
- WordPress not choosing the right image from srcset
- Responsive Images in WordPress
- What is the best way to handle Ajax image upload on front end?
- Display ajax preloader for large images within posts
- Is there a good way to use CMS images with CSS
- Image Attachments Query Not Working If Post Is Loaded Via Ajax
- Remove one srcset entry from wp_get_attachment_image
- Generate / attach Image srcsets from ACF Image Field
- Remove srcset thumbnail attribute for products in the WooCommerce shopping cart
- wp_get_attachment_image with custom size not rendering possible 2x srcset image
- medium_large image size not displaying properly on the frontend?
- ‘apply_filters’ is breaking some shortcodes/HTML but not all
- how to get original image using wp_get_attachment_image_src
- Is there a hook which fires after all thumbnails are generated?
- “There has been an error cropping your image” when cropping image
- WordPress Image Editor doesn’t update thumbs specified with `add_image_size()`
- How can you upload an image from within a settings page?
- Get an image from url in front end submission form
- Add visual editor to Media Edit Screen
- Use Gravatar as fallback image if no local image is not found
- Retrieving an alt tag from a custom field
- Exclude featured image from gallery in wp-admin
- Customizing the attachement page to show rest of all images in a gallery from post
- Importing images results to wrong folder structure
- WP keeps looking up post thumbnail on https even though wp-config says http
- How to post a mosaic of an image gallery instead of the entire gallery inside a post’ [closed]
- using media_sideload_image with a file from theme directory
- Why does WordPress convert my jpg’s to png?
- How to make my site use HTTPS for images or how to insert images as relative paths?
- How can I use wp_save_image_editor_file filter?
- Featured Image or Post Thumbnail Displaying on index.php?
- How to set featured image from external url programmatically
- How to display image in mail header using wp_mail()
- Redirect Image Url to a page via htaccess
- How does wordpress name resized image copies?
- Media Editor uppercase extensions to lowercase
- How to get rid of undefined variable in previous post image
- Custom Image Widget
- Register an embed handler for self hosted images
- Dashboard Create Gallery missing
- Get image thumbnail size urls in media library
- WordPress is showing blank lines instead of images
- Change header image size
- How to disable post-thumbnail from generation?
- js alert in add_filter function for image_send_to_editor
- all images of past post messed up after changing theme
- Where is this folder [closed]
- Different image heights for different resolutions without distortion
- Image editor not working correctly
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- Aviary + WordPress Media
- Issues with the excerpt (wordcount/HTML/images)
- Adding social share buttons for individual images on a web page
- How to get the attribues (alt and title) of an image import with ACF [closed]