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:
- 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?
- 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
- Run shortcode before filters
- How to change post thumbnail title and alt attributes to post title?
- add_image_size is scaling, even though crop is set to true
- Get password when user registers and save it sha1 into database
- Autogenerated Thumbnail compression depending on size
- Replace Home with image link inside custom header menu
- How to regenerate thumbnails when they’re stored on S3
- customizing the_password_form filter
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- A mystery 300px image size
- Lazyload post thumbnails
- Can’t show custom post thumbnail sizes as background images
- Custom Field returning Numerical Value for Image rather than URL
- How check that there is post thumbnail feature image or not on wordpress?
- If I Regenerate Thumbnails, would WordPress delete the existing Thumbnails and replace them with ‘new copies’?
- Featured Images are not able to be set
- Menu item added in wp_nav_menu_items filter is never highlighted
- How to make a local cache of mshots images
- Pass variable to hook. Its possible?
- image url relative path not working in css file
- How to stop thumbnail generation from some images and different size thumbnail generate
- How to stop wordpress always displaying full-res images
- WordPress taxonomy and archive custom class
- Responsive Images – crop don’t seem to work
- Can’t generate thumbnail images
- Reactor Theme: Prevent Post Thumb on Post
- “Medium” size image displayed instead of “thumbnail” in only one post, other posts are fine
- Inserting images in multiple posts native gallery
- Can I get the ID of an inserted / linked image?
- What is the meaning of WordPress’s recommended css classes and where are they applied?
- ‘Post-thumbnails’ feature does not seem to register
- Theme thumbnail in dashboard
- How to rotate every letter in a title
- the_post_thumbnail() get the URL to the “medium” sized image
- CSS class on last post in loop ( custom query )
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Use a filter on menu items that have children
- Theme logo metadata into template file
- Else/If Statement to Display Photo Descriptions
- Full width featured thumbnail
- adding image to post thumbnail from another server
- Filter didn’t work on content class (hybrid_post_attributes)
- How to add cropped custom header image?
- Related Post Category Filter
- Pagination don’t work with active filters
- restrain filter on get_the_excerpt to queried item in stead of current post
- How to use default image as featured image by implement some code in function.php
- WordPress Multisite: Images moved to /sites/1?
- Image cropping isn’t working correctly when using Offload Media
- I cannot upload images to post or the media library in wordpress
- Created blank theme for REST API, featured image not appearing on admin side
- Why image Thumbnail url is not displaying with custom size?
- Alt header logo and link for specific pages
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Can’t upload images on new theme
- image sizes – finding and removing
- Hook in parent theme Menu function
- How to add custom nav_menu_css_class to certain menu only?
- Adding a Class to an Getting From Post Content
- Featured Image Module Randomly Disappears
- get the post thumbnail returns the full size
- How do I keep images in posts below a certain size without editing the post?
- Making a thumbnail if there exist a link with. jpg or .png extension in WordPress
- the_post_thumbnail fetches wrong image
- Show post thumbnail only if it exists using timthumb
- WP is showing wrong image dimensions
- How can I add a single image from a gallery into the page header?
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Only show read more text when when wp:post-excerpt meets excerptLength