Get mobile Slug of an Assets from config.json (SDK)
Hello folks,
i have a problem to get the Asset on Mobile (SDK).
Background Informations:
I configure the config.json like:
"contents": {
"video": {
"teaserVideo": { "type": "asset", "value" : ["069d05309cf1a5fe9de0381030c9f541"]}
}
}
When i grab the asset in my app through my injected config.json i get the same object with additional parameter "results" back.
When i try to fetch the Asset URL from the Library like:
window.ShowpadLib.getAssetFileUrl(asset.id);
I get on Desktop the URL on Mobile not. Of course the documentation says i need the asset.slug for mobile. Something like this:
window.ShowpadLib.getAssetFileUrl(asset.id, asset.slug);
But the config.json didn't return the whole Asset (also not the slug) only the ID of the Asset.
The Problem:
- The asset.id is different on Desktop and Mobile (can't loop through all assets and filter by id to get the slug)
- I only get the slug when i am using the API, but the API doesn't work offline on mobile
The Question:
- How to get the ID and the Slug of an Assets which is connected through the config.json in SDK?
- It would be better to get the whole Asset as Object through the config.json (SDK)!
-
Solution:
When config.json URL (you get it from a GET Parameter from the current page) gets requested from a XHR. Showpad provides a "compiled" config.json as response. In which you can access the new json entry: "assets". You will find all informations you need to now about an asset. Don't be afraid, you will see Dummy-Content when you show up your config values in the console. Just insert it and you receive your needed data.
0
Please sign in to leave a comment.
Comments
1 comment