I recently built a similar plugin [1] inspired by a bug report I had to resolve at work. Back then I had hard time trying to find a good open source solution and this one here is nearly perfect. It's a little bit sad I didn't see it coming earlier.
You can check how cloudimage-responsive works here [1] [1] https://medium.com/cloudimage/responsive-images-in-2019-now-...