Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i config image path URL ? #35

Open
lctone opened this issue Jun 27, 2022 · 8 comments
Open

How do i config image path URL ? #35

lctone opened this issue Jun 27, 2022 · 8 comments

Comments

@lctone
Copy link

lctone commented Jun 27, 2022

Hello guys,

I want to config domain to image path URL

Image data save right now
/assets/c99aa974-6132-4a6a-8442-5c1e162454a8

Config save to this
https://domain.com/assets/c99aa974-6132-4a6a-8442-5c1e162454a8

Great extension, Thank you

@lctone lctone closed this as completed Jun 27, 2022
@Slembit
Copy link

Slembit commented Jul 26, 2022

Hi!
Did you solve this? I need to fetch the image from another editorjs instance in another application with another domain and was wondering the same hehe

@dimitrov-adrian
Copy link
Owner

The reason I didn't set absolute URL to the output for the images is because the portability, and if you already access it through the API, then for sure you are aware with the domain, so you simply could put it.

Anyway, as this seems to be asked more often, I can think of adding a URI property (which will be quite ease) with absolute address, the only think I am not sure if it's good or not is to add field for a static token or not.

@Slembit
Copy link

Slembit commented Jul 26, 2022

Wow fast response!
I think it could be interesting to add the ability to manually do it, but maybe not necessary if there is a way to handle it dynamically.

How is the url constructed today? I’m thinking, if it’s possible, to use the configuration invironment variable PUBLIC_URL (or maybe some other unknown to me better variable) and then append the path to assets and image.
In that way, it would be reachable from another application. But maybe that’s the way it’s constructed today?

@dimitrov-adrian
Copy link
Owner

dimitrov-adrian commented Jul 26, 2022

Well, internally it uses the {baseUrl}/assets/{file.id} (according the docs), where the baseUrl is PUBLIC_URL env as you already mention.

And for token it uses the current user's token, which is not good idea to be added to the output because of possible leakage.

Anyway, it might be really good idea to add it to the final output as separate uri or guid property with an optional static token configuration field, I'll try to do it in next days.

@Slembit
Copy link

Slembit commented Jul 26, 2022

Okey haha, lucky guess from my side.

just to be clear, when you say “add it to the final output as separate uri“ are you referring to adding the complete uri of the image, including the baseurl to a different key in the image meta-data structure? Because I’m thinking this: What if one of the editors is in a directus invironment, and the other editor is used in an angular project, wouldn’t it be better if the image url is always stored as the complete uri?
that way both editors would work without having to convert the image path.

but maybe I’m missing something here

@dimitrov-adrian
Copy link
Owner

dimitrov-adrian commented Jul 26, 2022

Yes, there are couple of cases where this is not the most suitable, for example:

  • domain is transferred/changed, then the content will point to the old one, so the stored JSON need a migration as well
  • if the directus is used on dedicated domain (protected), but the assets are served through proxy, so the domains will mismatch

So in such cases, it might be more reliable to use fileId or url

@Slembit
Copy link

Slembit commented Jul 26, 2022

Ah yes. that is correct... didnt think of that

@m0sth8
Copy link

m0sth8 commented Apr 24, 2024

Also editor.js requires full path:

file - uploaded file data. Must contain an url field with full public path to the uploaded image. Also, can contain any additional fields you want to store. For example, width, height, id etc. All additional fields will be saved at the file object of output data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants