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
- Media Upload Folder – how to manage
- Wrong image dimensions in Insert Media after add_image_size()
- Upload multiple images in a custom metabox
- Responsive Images
- How can I hide media library images from general users?
- How to add php to theme to show alt attributes
- Using Taxonomy Image code with my get_categories code
- Rename image during upload using date and time stamp?
- Images in the Twenty Fourteen theme
- Get author ID with attachment ID
- wp_get_attachment_url with specific image_size?
- Bulk edit Gutenberg single images to change from linking to media file to attachment page
- In Wordress one author can not see the other’s author uploaded images through media library
- Why are images created by WP larger than the original uploaded image?
- How do I fix “Sorry, this file type is not permitted for security reasons”
- Responsive Images – crop don’t seem to work
- Frontend Image Upload
- Multiple variables through wp_get_image_editor
- Removing featured image from gallery?
- Get image url using image id
- Images don’t update after being edited
- Large image not showing dimensions in Media Library
- How to insert image path in database to display product image in wp-admin?
- How can I externally retrieve a post’s custom sized image
- View photo album without having to scroll down for each picture
- How can i sorting and display image order by siz in media library?
- Media Library Cleanup A Thought Exercise
- Save media files (images) to database instead of the filesystem
- i want to change URL of WordPress image or rewrite in runtime
- After migration, all featured images using accentued characters in their file names are displayed “blanked”
- Adding numbers to an image based on co-ordinates
- A query to substitute images paths in gutenberg (website migration)?
- WP Large Images crash page
- How to display posts with images in fullscreen slider
- Prevent WordPress from creating individual size images
- Why doesn’t WordPress make thumbnails for videos?
- Plain image uploading – no links, no classes, no sizes
- Thumbnail gallery by date and taxonomy
- > added to images link in WordPress
- Insert image doesn’t pickup right size
- Thumbs and pictures not showing anymore
- Images will not attach to posts after site migration
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- Forcing absolute src links in the RSS feed
- WP_Image_Editor – How to save the new size of the image in the sizes metadata
- Could a very long article slow down all website and wpadmin?