I cannot get the image URL - I tried buildingImage.fields.file.url, and so forth but I keep getting back null. Please see the image attached. buildingImage is a linked image asset. It is returned in the query but I cannot get the URL from the response.
Also, for location, it was being returned as text before then suddenly it’s only returning lat/long. Can I get a string? Or do I have to use GeoCoder?
to answer your question fully, do you mind sharing what typebuildingImage is? If it is a CDAEntry, with a field linking the asset, something like this might be working:
val asset = result.getField<CDAAsset>("media")
val url = asset.url()
Please see that the media field of an entry links to an asset. if you have an asset, you can ask the .url() method to get the protocol less url. You would need to add https: to it to make it a complete url.
To answer your second question: You cannot get the location as a string. The location object is the only one supported. You would need to get the field and then call use it as a map to get its “lat” or “lon” value in Double.
Hey, Mario. I want to ask a further question. If in contentful model, we set the image field as optional. And in BE codes, how do get this image url? I mean mainly the return type of the image, like do we need to declare that the CDAAssets is nullable? like this one below: item.getField<**CDAAsset?**>("image")?.urlForImageWith(ImageOption.https())
Or the CDAAssets cannot be used as nullable because it is not basic types like Double or int