Image URLs - transforming DAM source URL to end user URL

New to Cloudflare so apologies if this is quite a basic question.
I just want to verify that it is possible to control the public URLs for our images so that they conform to our desired naming convention, rather than having to use the full URL of the source URL from the DAM that is serving them to Cloudflare.
Specifically, the DAM is including an idhash field within the URL that is not part of our naming convention, example below:

https://damdomain.com/m/12766cdf4a20e5e4/webimage-123456-front-2000x1125.png

So, we want to remove the idhash and extra / (12766cdf4a20e5e4/) for the URL that we use on our website to retrieve the image. I’m just looking for confirmation that this is possible to do with Cloudflare or are my expectations unrealistic. I’ve read about Workers, URL Forwarding, Redirects, in the Cloudflare user documentation, so assume if it’s possible, then it would be one of these functions that we could use to achieve what we are looking for.
Thanks in advance for any help received.

Can you provide an actual example of the URL that you will have the browser send and what you want to receive on your server eventually?

Hi Sandro.

So we want the browser to send:

https://mydomain.cloudflare.net/images/webimage-30605057-angled-2000x1125.jpg

the URL for this that is received by the Cloudflare server from the DAM is:

https://bynder.apps.mydomain.com/m/72174020cf003f8e/webimage-30605057-angled-2000x1125.jpg

I hope that’s the two URLs that you were asking for.

What do you mean by “received”? Do you want to change the URL when it is requested or do you want to change the HTML output your servers sends (via Cloudflare) to the client?

We want to change the HTML output our servers send (via Cloudflare) to the client.

So you basically want to replace m/16-character-string with images, right?

Neither redirects nor page rules would help you here, you’d need a custom worker for that. You’d essentially take whatever your server returns and run a search-and-replace to do aforementioned task.

You could also look at https://developers.cloudflare.com/workers/reference/apis/html-rewriter/ in this context.

Yes, exactly that, we want to replace m/16-character-string with images.
I think I’ve seen an example Worker script that does something similar. I will take a look at the html-rewriter link, thanks for all hour help, it’s given me the reassurance that my expectation is not completely unrealistic.

Not unrealistic at all. That should be fairly straightforward with some custom JavaScript code.

Workers are pretty powerful in this context, however they are typically a paid feature (unless you can work within the limits of the free plan). HTMLRewriter is somewhat new and still limited, but should be able to do the trick in your case anyhow.