Change host domain for Image module fields

Hi - we’ve got some custom email templates that use image module fields e.g.
{{ module.image_field }}
But when it outputs the image url it uses the HubSpot CDN
e.g.
https://xxxxxxx.fs1.hubspotusercontent-eu1.net/
Rather than our branded domain, I have set our branded domain to be the default domain files, any ideas how can change this for HUBL image fields as well?

Hey @JWright76, great question, thanks for asking the HubSpot Community!
I’d love to put you in touch with our Top Experts: Hi @Anton, @Sjardo and @HubDoPete do you have any insights to share with @JWright76, please?
Thanks so much for your help!
Bérangère

Hey @JWright76,

there’s a somewhat hidden setting for this hidden in the portal settings.
You can find it here:
Settings (gear icon top right) → Content → Pages → SEO & Crawlers → Default file hosting domain.
Or simply click this link and select your portal. :slightly_smiling_face:

Just set it to your desired domain and all files should get updated to the selected domain.

Another option is to manually open each file in the file system and select the domain from the dropdown (next to the copy URL button)

best,

Anton

Thanks, but I set that and it doesn’t change the output when using HUBL variables. For now I’ve had use a crude string replace function.

Hi @JWright76 and thanks for getting back to us!
The default file hosting domain setting doesn’t always carry over to HubL image module field outputs.
At the moment, using the string replacement is the way to go. You can actually use the HubL replace filter right in your template like this:

{{ module.image_field.src|replace(“xxxxxxx.fs1.hubspotusercontent-eu1.net”, “yourbrandeddomain.com”) }}
This should help seamlessly update your image URLs.
I’d also recommend leaving your feedback via the HubSpot Developer Feedback Form. If you’d prefer, I can submit it on your behalf, just let me know.
Thanks,
Bérangère
This post was created with the assistance of AI tools