starlette-admin icon indicating copy to clipboard operation
starlette-admin copied to clipboard

Enhancement: ImageFromUrlField

Open sglebs opened this issue 1 year ago • 3 comments

https://jowilf.github.io/starlette-admin/api/fields/#starlette_admin.fields.ImageField lists UrlField (makes URL clickable) and lists ImageField (based on files). How about an Image Field that contains an image URL instead of the image bytes? Maybe ImageField could be changed so that it does not assume it is a file? (I tried it, on the column that has a URL, and it did not work).

Do we need to implement "ImageFromUrlField"?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

sglebs avatar Aug 31 '23 15:08 sglebs

You can create a custom field that inherit UrlField and customize the list & detail rendering. feel free to submit a PR

jowilf avatar Sep 01 '23 02:09 jowilf

These template files... I just need to create a directory off the top of my project and put the html there? Is there a "search path" mechanism? Like "first I try to find it in the project where I am running, then in starlet-admin's dir, then...".

I mean, if I create a /displays in my project and save my own customized url.html there, then the URLField will automatically render my way?

    display_template: str = "displays/url.html"

It turns out the URL I will have to embed may be an image or an audio or a video, so I will probably need to implement a MultimediaFromUrlField and put the logic in to generate the best HTML markup.

sglebs avatar Sep 02 '23 13:09 sglebs

By default, starlette-admin will search in your templates directory. You can customize it by providing a custom templates_dir https://jowilf.github.io/starlette-admin/tutorial/configurations/admin/

jowilf avatar Sep 02 '23 14:09 jowilf