Try selecting the render function?

```
val render = imageMimeType filter { media.mediaSubType == "webp" && ServeWebPImagesSwitch.isSwitchedOn } map { renderWebp } getOrElse { renderJpeg }
wsRequest map { render(path, imageCacheLifetime, profile) }