Hi,
I have a schema with a bunch of fields. One of those fields is an image/Asset. When I create a new page from that schema, I select an image, save the page, and the page data gets written to mongo in JSON:
"image": {
"iv": [
"54fa22f2-768f-4192-b4c9-473b1fec8122"
]
}
Note that it’s just the GUID, and not the full image URL.
What I would like is that when I save the page, the full URL of the image would get saved and the JSON would look like this:
"image": {
"iv": [
"https://mysquidex.domain.com/api/assets/54fa22f2-768f-4192-b4c9-473b1fec8122"
]
}
Then on the front-end I would not need to do any extra work, I can just fetch that value like I would with any other regular string field.
I could solve this by:
- Adding a new
imagefullurl
field of typestring
to my schema. - Create a new page of that schema, and select an image (
image
field). - In Google Chrome copy the image URL from inside the Squidex UI for the page your editing:
https://mysquidex.domain.com/api/assets/54fa22f2-768f-4192-b4c9-473b1fec8122?q=1332b423-ab76-c237-d71c-3b3e4800eb0a
- Remove the
?q=1332b423-ab76-c237-d71c-3b3e4800eb0a
part. - Copy and paste
https://mysquidex.domain.com/api/assets/54fa22f2-768f-4192-b4c9-473b1fec8122
in the newimagefullurl
field. - Save the page.
You can now create your img tags like this (ASP.NET Core):
<img src="@Model.Data.ImageFullUrl">
My question is: Is there an easier/smarter/faster way?