Rather than messing with it yourself, this is a great scenario in which to consider offloading it to a third party (and also using modern formats like WebP). Something like PicPerf.io or other optimization plugins out there.
Related Posts:
- optimized PNGs 5X larger than originals
- Cannot get full thumbnail size using the_post_thumbnail
- How to disable thumbnail filter for a specific template part or image size?
- The the_post_thumbnail without srcset?
- Get the first image from post content (eg.: hotlinked images)
- How to modify an image block in Gutenberg WordPress 5?
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- Unexpected width and srcset attributes for the_post_thumbnail();
- How to set dimensions of the post thumbnails (featured images)
- Disable wordpress image sizes generation
- Reasons why all thumbnail sizes aren’t working
- How do I Add images uploaded in the post to a default custom field
- How do I turn a post thumbnail into a background image?
- Redirect to another page using contact form 7? [closed]
- Filter for post_thumbnail: link to small src and add data-attribute [duplicate]
- How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?
- How to make excerpt image be full size instead of thumbnail?
- How can I scale down the width of images in bulk that are embedded in posts throughout the site?
- Add image URL automatically to custom field?
- theme directory fallback image outputs url and not the image
- Full width thumbnail
- Any disadvandages if I style the wordpress align classes without img and .wp-caption prefix
- apply_filters to featured image
- Add rel to all images in a post
- I want to resize post featured image without cropping image. How?
- Filter to remove image dimension attributes?
- WordPress Theme Preview Image
- How to disable WordPress from creating thumbnails?
- set_post_thumbnail_size vs add_image_size
- the_post_thumbnail responsive srcset not populating with custom image size
- New image size version only for the Featured Image file
- How to remove the Theme Customization Button from the dashboard and themes options page?
- What filters are applied to the_content function?
- Is there a hook which fires after all thumbnails are generated?
- Change admin bar to default:off
- How can I set image sizes and still have responsive images using the srcset attribute?
- Add default Backgrounds
- Change WordPress image URLs via filter
- get_the_post_thumbnail_url with an unregistered size
- Cropped featured image replaces original image in gallery
- How to add a 2nd “featured image” to a post?
- Remove title attribute from images
- Specify image dimensions
- How to get gallery images?
- Display a different theme for not logged-in users
- Run shortcode before filters
- Add class to before_widget for all widgets with a dropdown and a counter
- How to change post thumbnail title and alt attributes to post title?
- add_image_size is scaling, even though crop is set to true
- Featured Image in 4.4 should be larger on mobile device
- How to Auto Approve Comments on a Specific Page?
- How to use the responsive images feature from WP 4.4 in your themes
- Can WordPress crop only the post thumbnails?
- Confused about image sizing business in WordPress
- Get password when user registers and save it sha1 into database
- How do I get gallery thumbnail URL and change the default thumbnail size?
- No srcset for hard-cropped thumbnails
- Autogenerated Thumbnail compression depending on size
- Responsive class to all the images in the content
- Passing variable in hooks and filter
- How to use SRCSET with get_the_post_thumbnail()?
- How wordpress handle upload images and how to use them in the code
- How to handle thumbnails
- Removing Title Tag from Thumbnails
- Replace Home with image link inside custom header menu
- Featured Image Size
- Changing playlist shortcode thumbnail sizes?
- Change display of featured image for pages in twenty seventeen theme
- WordPress nav_menu_css_class theme filter is not being called
- How to regenerate thumbnails when they’re stored on S3
- customizing the_password_form filter
- WordPress Genesis Child Theme Filter divs
- Save image as featured image
- How to make thumbnail image fit into a div where image dimentions are completely different?
- Change file name from wp_generate_attachment_metadata
- Thumbnails produce unwanted gray pixels on white background [closed]
- wp_get_attachment_image_src() width and height boolean
- How to float an image in Gutenberg
- A mystery 300px image size
- Lazyload post thumbnails
- Simple way to get two language WP site
- Can’t show custom post thumbnail sizes as background images
- Custom Field returning Numerical Value for Image rather than URL
- Show featured image next to post-teasers in Genesis Framework?
- How check that there is post thumbnail feature image or not on wordpress?
- Highlight “Show all” item in wp_list_categories
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?
- How to removes all instances of thumbnails displayed in my theme?
- Featured Images are not able to be set
- Why an arugment is missing in wp_get_attachment_image_attributes?
- Display recent posts with thumbnail
- Menu item added in wp_nav_menu_items filter is never highlighted
- How to make a local cache of mshots images
- How to get cropped thumbnail source for custom post type
- Should I use add_filter for functions in function.php of the theme?
- Pass variable to hook. Its possible?
- attachment.php code or tutorial
- Change “Thumbnail”, “Medium” and “Large” image sizes using functions.php?