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
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- Download an image from a webpage to the default uploads folder
- Allow contributor role to upload images and not edit already published articles
- wp_get_attachment_image_src and server path
- Limit image resolution on upload
- 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
- Upload multiple images in a custom metabox
- hook into completed image upload filter
- How can I hide media library images from general users?
- Images uploading to wrong folder
- Programatically creating image attachments from local URLs and setting featured image
- Get Attachment ID from URL [duplicate]
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- Applying class to links around self hosted images embedded to posts/pages
- Filter to modify post_title after image upload?
- Pulling Post Image Attachments in WordPress 3.9
- Automatically Add Caption in image
- Rename image during upload using date and time stamp?
- Link Featured Thumb to Attachment Page, If Possible
- Custom image size not regenerating when image editted
- How to disable the suffix “-scaled” which is being added at the end of each uploaded image?
- Image still linked as attachment to page even though it has been deleted
- What’s the best “insert all images” plugin?
- Is 700,00 jpgs too many for a WordPress site.?
- Add a new data attribute in tag
- Local WordPress installation doesn’t crop images
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- Generating different dimension images while uploading image file from custom plugin page
- is it possible to crop cover images in buddypress?
- Can’t seem to attach uploaded image to post and set it as thumbnail
- Bulk edit of EXIF data for jpeg images uploaded in the media library?
- Image upload appearing as broken images following server move
- Get image URL after image created from canvas and sent to WP uploads with AJAX
- How to stop thumbnail generation from some images and different size thumbnail generate
- How do I fix “Sorry, this file type is not permitted for security reasons”
- How to implement secure frontend image upload? [closed]
- wp_upload_bits Upload Specific Sizes Only
- Change wp-content/uploads to uploads/%postname%/%image%
- WordPress images not cropping properly
- wp get attachment image always gives me thumbnail
- How to get the real file type for images that do not have an extension
- Images are not showing up in “Uploaded to this post”
- Images don’t update after being edited
- Upload attachment from external site
- Images not found after migrating WordPress website
- Error uploading images in wordpress
- Capitilize Alt/Title Tag in Image HTML, Reorder HTML Output
- What is the best way to associate multiple images to one page?
- How to get the cropped image from media library?
- VT-resize (great alternative to timthumb) : Errors cropping (litespeed, centos 6.3)
- Random Characters in the end of every image url in post
- WP_Query: attachment image in “full” size?
- Attachments without images
- Plugin to select the custom image crop area
- Apply manual image cropping not to thumbnail but medium_large size
- Save media files (images) to database instead of the filesystem
- Trouble with Uploading and Displaying Images
- WordPress Multisite: Images moved to /sites/1?
- wp_insert_attachment() dupplicate attachment posts
- How to get attachements URL from author meta and display them?
- How to stop a post from publishing if the file upload is not a image/gif
- What is the best way to handle Ajax image upload on front end?
- 403 Forbidden when accessing image in wordpress
- variable crop option with add_image_size()
- problem with updating metabox of upload image
- Missing Images in Uploads Directory (Server Only)
- Media upload in add comment meta box
- How to access & display images from a post without textual content ( and vice versa) according to best wordpress practices
- My image rotate 90 degree
- Set image dimension for WP_Customize_Image_Control images
- What type to upload image within theme options?
- How can we see which posts don’t have a featured image or it doesn’t exist anymore?
- Can’t manage to display an uploaded picture (uploaded from a custom button) in the front end
- My subdirectory sites images (except webP) are throwing to 404 page even they are exist
- How can I use an image from an external source without uploading it to the media library
- Can’t upload svg files in WordPress
- Random images from uploads folder and subfolder