The answer is to not generate more image dimensions (and your theme overriding user settings is a big no no), but to select the best fitting image bt size and apply css based stretching and cropping by wrapping the img
element with a span
.
The to the img
you use whatever is the best fit, and then by using a combination of relative positioning in the span
and changing the image size you can get whatever effect you want.
This is really just a “view port” technique that is as old as CSS, the only wordpress specific part is to pass to the sizes that you want to the_post_thumbnail
as the first parameter.
The gotcha with this is that obviously if wordpress gives you a cropped image you can’t “uncrop” it, and you will have to add your own image size setting for that.
Related Posts:
- Original image not saving?
- No Thumbnails Generated
- Which filters or actions to use after a media upload and delete?
- Convert uploaded PNG to JPEG automatically
- add_image_size creating lots of images (of various sizes)
- WordPress won’t generate image sizes for certain images
- Thumbnails produce unwanted gray pixels on white background [closed]
- Site icons with alpha channel for self-hosted WordPress blog network
- Can I stop wordpress generating media sizes
- add_image_size() and uploading the exact size leaves 1×1 image in uploads
- Attach Thumbnail Generated from Video Upload as Featured Image for the Video
- WordPress Media Library showing wrong preview size?
- Redirect to another page using contact form 7? [closed]
- Resize existing library images
- Issue with images which have no sizes available
- What is the URL pattern for image thumbnails + sizes?
- Dynamically determine the width and height of a image file to be cropped & uploaded AFTER form submission given fixed aspect ratio
- Removing extra large generated images disables all crops
- Images uploaded via Gutenberg image block are cropped
- get the post thumbnail returns the full size
- Is there a way to force Featured image to show as attachement?
- Question regarding the file path for media_sideload_image and wp_upload_dir()
- How to Fix HTTP Error When Uploading Images?
- How does WP media uploader create the 3 different sized images, and how can I duplicate it
- Reject upload of wrong-sized images using the Media Uploader
- Download an image from a webpage to the default uploads folder
- Users can’t upload images on frontend if they haven’t got access to the wp backend
- Create image formats with different qualities when uploading
- Protecting direct access to PDF and ZIP unless user logged in (without plugin)
- How to restrict images in v3.5 Media Library modal to only those from a specific post id?
- Why are double-periods (“..”) invalid in a WordPress image filename?
- How can I speed up a slow loading media library?
- What to do with unattached logos and header uploaded via native wordpress uploader?
- How to prevent upload of a multiple sizes of images
- Impose a Maximum Limit on Image height and width upload size
- Force wordpress to see uploads folder media
- Add item to media library from blob or dataUrl
- How can I add the “Use as featured image” to a custom metabox?
- WP3.5 Media Uploader – how to make it accept multiple images?
- WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account
- Add new media uploader at frontend for wp 3.5+
- resize images not crop
- Trying to add filename over image in Media Browser
- Upload image from a URL and assign it as a Featured Image to a Custom Post Type?
- Regenerate thumbnails after upload
- Media library storing files in uploads not folders within in uploads
- Adding a querystring to an image URL when clicking ‘insert into post’?
- Is there a limit on the number of attachments?
- Frontend Post – Allow Only Image File Upload
- how to use media library [closed]
- Cannot upload .mp3 file to wordpress media
- HTTP Error when uploading files above 7mb unless using GD Image Editor
- WordPress Fancybox Resize Large Image
- 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?
- WordPress auto generates small medium and large of an image on upload, how can we guess their links?
- How to stop thumbnail generation from some images and different size thumbnail generate
- Error uploading image in WordPress
- Stop WordPress from generating redundant image size
- WordPress 4.9.8 Trying to add filename over image in Media Browser
- wordpress media upload given An error occurred in the upload. Please try again later
- Using wp_enqueue_media() with switch_to_blog() issue
- Media library only shows for admin. Doesn’t show editor or below [closed]
- Upload featured image from front end using media-upload.php
- Can’t generate thumbnail images
- Change media URL (images)
- Images are not showing up in “Uploaded to this post”
- A link (not in the post) to download a specific PDF file
- How to change format of file link ( Name ) when insert from media uploder
- Images don’t update after being edited
- Set different max upload size limits based on file type/extension
- Correctly using the root directory for media uploads?
- How to allow .bin files upload?
- Add SWF file to wordpress through custom template
- How to detect when a file has been uploaded?
- Cannot upload featured image to a custom post type
- Uploaded images result in a file url with full path on disk appended
- Is it possible to limit number of files a non-admin user can upload via the WordPress media library?
- Multiple images are generated in WP-content in wordpress
- MIME types not recognized by media library
- WordPress Multisite: Images moved to /sites/1?
- Images not displaying on site or media library
- Bulk upload images in upload folder does not show in media library
- Media not displaying other users uploads – WordPress 4.9.2
- Featured image to grayscale with PHP imagefilter – which hook to use?
- Issues with WordPress 3.9.6 media libraries on XAMPP
- Private file system for attachments
- How to split my uploaded media into directories?
- Missing Images in Uploads Directory (Server Only)
- Metabox with file upload to custom directory
- How to force attachment size for every post
- Is it possible to upload multiple images via Media Library tab in Thickbox I’ve created?
- Make thumbnail from uploaded image without plugin
- Transfered live site to new server and images are not showing
- Limit files uploaded per folder
- Link or button to open the media manager from frontend
- Bring up the media uploader on click
- Why some images are not allowed to be edited only for thumbnails?
- 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