We use WordPress as a headless CMS and retrieve post data via REST API endpoints. Currently, images in the API responses always return their original JPG/PNG URLs, even if a WebP version has been generated.
It would be really useful if the REST API results reflected WebP URLs whenever available—either as a replacement for src attributes or as an additional field in the API response.
Expected Behavior:
– If a WebP version exists in /wp-content/smush-webp/, return that URL instead of the original.
– If no WebP exists, fallback to the original JPG/PNG.
– Apply this behavior to content.rendered, ACF image fields, and other media fields in the API response.
This would help optimize performance for headless setups using Next.js, Nuxt.js, or other frontend frameworks where automatic image optimization is not active (we often have to turn it off as a result of high fees).