srcset
is populated with all sizes of the image that are the same aspect ratio as the original image.
The reason smaller images are added to srcset
if you upload the exact size is because that means that the default resized versions like medium
and large
will have the same aspect ratio. However, when using a custom cropped image size those smaller sizes will be created with the same aspect ratio as the original image, not the cropped custom size.
The solution to this is to register additional custom sizes with add_image_size()
that are smaller than the custom size but have the same aspect ratio. WordPress will then be able to use these to populate srcset
when didplaying your custom size.
Related Posts:
- How to delete resized (cropped) image uploads and prevent future resizing?
- Uploaded images don’t show in Media Library if there are special characters in IPTC Keywords
- Get attachment ID of author_meta image – Attachment Metadata
- Image resize with image url
- How do i upload an image and return the image id?
- How to upload image without post ID using the new media uploader?
- Rename attachments during upload
- add_image_size() to crop images into squares?
- media_sideload_image with rewritten urls?
- Handling image uploads without thickbox
- Auto delete attachments that are older than x days
- Show image crop window on image upload
- Does wp_get_attachment_image_src also work with non-image files?
- Get images attached to a specific page
- WordPress Creates Unused (Unregistered) Image Sizes
- Disable image rename on upload
- How to disable post-thumbnail from generation?
- Troubles with code for upload a image
- After I upload a file to library its name converted to dashes
- Upload unnattached image from frontend
- Image Upload from URL
- Programmatically adding images to media library
- 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
- Can I attach image to post without adding it to post?
- Upload images to remote server
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- Each custom image size in custom upload directory?
- Download an image from a webpage to the default uploads folder
- After Moving a Site to Another Domain, All Images Are Lost
- Why WordPress automatic cropping all my images?
- Allow contributor role to upload images and not edit already published articles
- Is there a hook which fires after all thumbnails are generated?
- Disable image attachment links
- wp_get_attachment_image_src and server path
- Limit image resolution on upload
- Rename files on upload
- How to insert images into posts without using Add Media dialog
- Using Images in WordPress – Best Practices
- How to find attachment by it’s name?
- Media Upload Folder – how to manage
- How to resize images in wordpress without adding any compression or changing the color profile of the images, possible?
- get_the_post_thumbnail_url with an unregistered size
- Cropped featured image replaces original image in gallery
- Prevent large image uploads
- Modifying an uploaded image with ‘wp_get_image_editor’ and ‘wp_handle_upload_prefilter’
- Upload multiple images in a custom metabox
- How do I delete all generated images from my server except those currently used in posts
- add_image_size() zoom-crop
- Insert an image into a post by API
- Function to call the attachment image from post
- hook into completed image upload filter
- Saving the pre-sanitized filename of an attachment as the Title or Caption
- Prevent image upload unless exact size
- getting uploaded SVG dimensions on front-end
- Adding upload button in metabox
- Use Media upload in custom widget on wordpress 3.5
- Theme Customiser Image Control
- Automating a Daily Picture Blog?
- How can I hide media library images from general users?
- How to copy and paste a picture found on the web to wordpress easily
- add_image_sizes ignoring crop sizes and using proportion
- Images uploading to wrong folder
- “There has been an error cropping your image” when cropping image
- Associate an existing image with a post
- Replace all of post’s image URLs with upload directory URLs
- Programatically creating image attachments from local URLs and setting featured image
- How can I add the “Use as featured image” to a custom metabox?
- How can you upload an image from within a settings page?
- Get Attachment ID from URL [duplicate]
- Alter media caption/description conflict in WordPress?
- How to remove title attribute from gallery links and images
- Separate attachment images from post loop
- Restrict the number of images to upload per post
- Automatically wrap post image in div
- How to display a shortcode caption somewhere other than the_content
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- How to increase media image scale limit?
- copy attachment title to description and alt text
- Frontend image uploading from edit profile page. (goldenapples)
- Get an image from url in front end submission form
- Open the attachment details modal
- How to Display an Image Uploaded through a Meta Box in a Template?
- How do I delete thousands of unattached images?
- Allowing post attachments without allowing to insert in text
- Cropping an image before inserting into a post
- Applying class to links around self hosted images embedded to posts/pages
- HTTP Error when trying to upload image
- Filter to modify post_title after image upload?
- Add suffix to filename of uploaded images
- Regex to turn embedded images in to attachments
- Re-process Images
- Uploading an image as featured image from frontend form
- Show prev and next post links for parent post of current image in attachment page?
- How to upload images from my directory into my wordpress?
- could not upload image in media library
- Pulling Post Image Attachments in WordPress 3.9
- Automatically Add Caption in image
- Uploading images to Media Library fails with Memory Exhausted