Dawid, thank you for that custom solution. I ended up discovering that this case is already handled by Kentico, so a custom solution is not necessary.
I configured a clean Kentico 10 web site to store only media files on Azure storage, (https://docs.kentico.com/k10/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-azure-storage#ConfiguringAzurestorage-ConfiguringKenticotostoreonlymediafilesonAzurestorage). Then, I configured Kentico to use a CDN, (https://docs.kentico.com/k10/running-kentico-on-microsoft-azure/configuring-azure-cdn#ConfiguringAzureCDN-ConfiguringKenticotouseaCDN). These were not Amazon storage or CDN resources because we do not have an active Amazon Web Services (AWS) account, but they should mimic Kentico's general approach to media files and external storage providers. After completing those custom configuration tasks, I applied hotfix 10.0.21 to ensure the Kentico instance was running the same hotfix as our client.
I tested adding several media files. The media files always used an absolute URL for the direct path and relative URL for the permanent link. The direct path's absolute url always began with the CDN endpoint URL.
I tested adding media files to pages using the Rich Text widget on the page tab. The img tag's src attribute always used the direct path and always began with the CDN endpoint URL.
These tests confirm that Kentico already handles adding the CDN endpoint URL to the direct path of media files. If Kentico fails to prepend the CDN endpoint URL to the direct path of media files, then Kentico is not configured to use a CDN. If Kentico fails to prepend the cloud storage URL to the direct path of media files or uses relative URLs for the direct path of media files, then Kentico is not configured to store only media files on cloud storage.
I suspect that our client was neither configured to store media files on cloud storage nor to use a CDN.