RaythaHQ / raytha

Raytha is a powerful CMS with an easy-to-use interface and fast performance. It offers custom content types, a template engine, and various access controls. It supports multiple storage providers and an automatically generated REST API. Upgrade your development workflow with Raytha.
MIT License
144 stars 30 forks source link

Allow urls to media to be the urls directly to the source, instead of redirect from Raytha #87

Closed apexdodge closed 1 year ago

apexdodge commented 1 year ago

Currently, when a file is uploaded, either via the Attachments field type, or if uploaded within a long text / wysiwyg field, the url that is generated is always something like /raytha/media-items/objectkey/abc.

The good

The bad

Proposal:

We add an environment variable under storage that, if turned on, will output the URLs to directly to the source storage. It will default to off though.

apexdodge commented 1 year ago

Decided to change the implementation here, simplified it, but I'm quite happy with the decision for now. This is now a choice for outputting the URL to the file via liquid filter.

1) Added a new filter attachment_redirect_url liquid filter which outputs the URL of /raytha/media-items/objectkey/{{ Target.PublishedContent.attachment.Value }} which is the same behavior as the current existing filter raytha_attachment_url.

2) Added a new filter attachment_public_url which will output the direct url to the blob on the file storage provider. A requirement of this method is that your bucket or container needs to have anonymous public-read access on the objects because it will not generate a presigned url or SaS url.

3) raytha_attachment_url is now deprecated. Consumers should switch to attachment_redirect_url in their templates to preserve the same behavior. To be removed in v1.0.6.