WordPress does not create any thumbnail on the fly. If you try to fetch a size that doesn’t exist, either the closest size or the full size image will be retrieved.
The closest solution you can try is to fetch a size larger than what you want, and then size it down via CSS and crop it.
Let’s say the registered sizes are 50 x 150
, 300 x 300
and 1024 x 1024
, but you need a 300x177
image. Fetch the 300x300
one, and then clip it using CSS:
#my-div img {
position: absolute;
clip: rect( 0px, 300px, 177px, 0px );
}
Related Posts:
- Cropped featured image replaces original image in gallery
- Is there a hook which fires after all thumbnails are generated?
- No srcset for hard-cropped thumbnails
- Removing Title Tag from Thumbnails
- Disable wordpress image sizes generation
- Lazyload post thumbnails
- WordPress crops images differently on retina screens?
- How to stop thumbnail generation from some images and different size thumbnail generate
- Update old Post image metadata to ‘thumbnail’ wp_attached_file
- How to stop wordpress always displaying full-res images
- Fixing image names for a site being restored
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- How do I get a smaller size of an avatar image
- Can we use featured image as third party website image URL
- add_image_size not working
- Product Images Low Quality After Updating From WP 3.5 to 4 [closed]
- adding image to post thumbnail from another server
- How to add thumbnails to posts and pages automatically in a uniformed fixed elegant way?
- Apply manual image cropping not to thumbnail but medium_large size
- How to use default image as featured image by implement some code in function.php
- WordPress Multisite: Images moved to /sites/1?
- I cannot upload images to post or the media library in wordpress
- Why image Thumbnail url is not displaying with custom size?
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- WP is showing wrong image dimensions
- Filter to remove image dimension attributes?
- How to disable WordPress from creating thumbnails?
- Stop wordpress from hardcoding img width and height attributes
- Programmatically get images by URL and save in uploads folder
- set_post_thumbnail_size vs add_image_size
- Custom image size / thumbnail – Crop to aspect ratio even when source image is smaller than set dimensions
- How to delete resized (cropped) image uploads and prevent future resizing?
- How to automatically add rounded corners to thumbnails?
- WordPress adding scaled images that don’t exist (1536×1536 and 2048×2048)
- Download an image from a webpage to the default uploads folder
- the_post_thumbnail responsive srcset not populating with custom image size
- How to change image type for specific size?
- New image size version only for the Featured Image file
- Why WordPress automatic cropping all my images?
- is it possible to replace the use of gd_lib with imagick or ImageMagick?
- Featured image shortcode
- How to find attachment by it’s name?
- Change WordPress image URLs via filter
- How to resize images in wordpress without adding any compression or changing the color profile of the images, possible?
- Image Scaling using get_the_post_thumbnail issue in WordPress
- Any easy way to automatically set the first inline image in a post as the thumbnail?
- Remove title attribute from images
- 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
- How to create thumbnails with a fixed width, so all of them will have the same width?
- How to limit number of images being printer out in “Set Featured Image” pop up?
- add_image_sizes ignoring crop sizes and using proportion
- “There has been an error cropping your image” when cropping image
- Black and White thumbnails
- Programatically creating image attachments from local URLs and setting featured image
- How can I add the “Use as featured image” to a custom metabox?
- Can WordPress crop only the post thumbnails?
- set_post_thumbnail_size not cropping featured images, but reducing proportionally
- Image resize with image url
- How to grab first image attached to post and display in RSS feed?
- Double thumbnails?
- Is it possible to prevent users from uploading small images?
- Can’t Display Featured Image in RSS Feed
- Displaying a featured image (only img url) as the img src?
- Autogenerated Thumbnail compression depending on size
- How to output placeholder image if no featured image set?
- Cannot access the thumbnails of attachment images… Cannot find the reason
- Cropping an image before inserting into a post
- Featured Images on Front Page
- Download button for Featured Image in every post – automatically
- Show prev and next post links for parent post of current image in attachment page?
- Setup A Default Featured Image
- When displaying the featured image, is has_post_thumbnail() necessary?
- Find posts without featured image? [duplicate]
- How do I add a featured image to a single post page?
- Why can’t I edit certain images from the WordPress Media library?
- Changing playlist shortcode thumbnail sizes?
- Add a featured image in my theme?
- Custom image size not regenerating when image editted
- Add_image_size not cropping
- How to make programmatic image upload generate thumbnail and sizes?
- Get original image from thumbnail URL
- Cannot get full thumbnail size using the_post_thumbnail
- WP 3.4 has missing photo data
- Featured Image .svg height and width 1px only
- Save image as featured image
- Display latest 12 images from media library
- Thumbnails produce unwanted gray pixels on white background [closed]
- How to check if user is uploading/setting an image as a featured image?
- Image Quality Thumbnail Compression in WordPress?
- Images are randomly deleted from server
- Frontend Post – Allow Only Image File Upload
- attach unattached featured images to respective posts
- Why does the Hard Crop option Scale?
- Images not working using Featured post
- Add instructions to featured image
- WordPress reduces the full size image and uses it as the original
- Local WordPress installation doesn’t crop images
- How do I get more image editing options in the admin?