Subdirectory to a file in new link-field 404

The new kirby 4 “link” field is great!
But the linked URLs in the content points to the URL-root, like
<a href="/@/file/someid">
And the file is not found if Kirby is on the kirby-subdirectory like /my-subdomain/.
I change the link-type from URL to “file” and select the file, then this happens.

How can I change the given file-URL globally to a subdomain like
/my-subdomain/@/file/abcdefg
When Kirby is installed on a subdomain?
The url setting in config.php don’t change this.

Is that a separate link field? How do you render it in your template?

Sorry, its the html-code, generated by the writer field. Changed the link-type from URL to file. Then selected like in the file-field.

Ok, so the links work fine, but you want to render the standard url instead of the permalink? Then $field->permalinksToUrls() | Kirby CMS to the rescue.

Whooop!
$field->permalinksToUrls()
is it and corrects the url to what I want. Thank you Sonja.

Ca I do this globally somehow?

I don’t think so.

Unless you use a hook (page.render.before, probably), and apply the stuff done in the permalinksToUrls method to the whole page data.

Thank you, works great. But if the Kirby is on a subdirectory, you always have to add the ->permalinksToUrls() for every writer-field. Otherwise those (great) function for linking sites or files don’t work correctly. On the root, all is fine.

Maybe better put the site on a subdomain, instead of a subdirectory.