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

The API should convert relative media path to absolute #3321

Closed
dtrucs opened this issue Nov 15, 2022 · 6 comments
Closed

The API should convert relative media path to absolute #3321

dtrucs opened this issue Nov 15, 2022 · 6 comments
Assignees

Comments

@dtrucs
Copy link

dtrucs commented Nov 15, 2022

From the description fields, it is possible to attach media. The src attribute is filled with a relative path instead of an absolute path.
Whatever service connects to the API should not parse the content to add the base path of the admin URL.

For example:
A description given by a trek endpoint https://admin-pyrenees-orientales.fr/api/v2/trek/254789/?fields=description
And below the UI for the user ⬇️
image

@Chatewgne
Copy link
Contributor

The relative path in question when displaying the source code for this description :

image

  • This pictogram insertion tool should insert an absolute URL in the src tag
  • It would be useful to write a migration for the old data, converting fields with relative paths to absolute paths, or at least a command that helps finding all fields that need an update

@camillemonchicourt
Copy link
Member

Hum, what about if we change the Geotrek-admin URL.
Not sure storing an absolute path is the good solution...

@dtrucs
Copy link
Author

dtrucs commented Nov 16, 2022

Hum, what about if we change the Geotrek-admin URL. Not sure storing an absolute path is the good solution...

Totally agree 👍
Ideally, I think the conversion should be done by the API looking at its basePath. However parsing the content with a regexp could go wrong (false positive).

Anyway, it is not flexible to work with stored HTML. Maybe in the future storing the content with markdown would make manipulations more flexible.

@bastyen
Copy link

bastyen commented Nov 17, 2022

Geotrek mobile handle this case here : https://github.com/GeotrekCE/Geotrek-mobile/blob/main/src/app/services/settings/settings.service.ts#L290

@camillemonchicourt
Copy link
Member

Fait dans la 2.95.0, mais je ne vois pas le résultat quand j'affiche une description avec un service intégré dans celle-ci :

image

Le chemin du picto du service est relatif : <img src=\"/media/upload/descent-icon.svg\" alt=\"Descente\" />

@camillemonchicourt
Copy link
Member

Corrigé dans la 2.98.1

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

No branches or pull requests

5 participants