How to automate image optimization for a wordpress site?

Consider this wordpress based site for an example - https://agatton.com/

You can use an image CDN like ImageEngine , which will automate the resizing, compression and conversion of image formats for the end users device.

You can implement it in Wordpress with the W3 Total Cache plugin
https://www.scientiamobile.com/4-steps-to-add-imageengine-to-wordpress/

Or you can use the themes function.php to implement it without a plugin
https://www.scientiamobile.com/easy-wordpress-image-optimization-without-plugins/