Skip to content

How To: Referring to assets uploaded to my awe app

awe.media edited this page Sep 20, 2019 · 5 revisions

This gives you an overview of how you can link to or reference the different types of assets you have uploaded to the media library within your awe app.

Referring to uploaded images

Once you upload an image to your media library you can click on the (i) button to get the asset id.

get_asset_file_url()

var url = awe.util.get_asset_file_url(asset_id, file_type, url_type, fallback_to_original);
if (url) {
  // you now have a URL for this file_type related to this asset_id
} else {
  // this URL could not be constructed for some reason - see console for warnings
}

This function accepts an asset_id and optional extras and if possible it returns a valid URL you can use to access this file_type for this asset_id.

If transcoding has not been completed yet then this function will return undefined.

If the file_type requested is not available then this function will return undefined (NOTE: See the optional fallback_to_original below).

asset_id

asset_id is an integer. You can get this by clicking or tapping on the (i) icon on the thumbnail of your asset in the media library.

file_type

file_type is an optional string and the supported file types depend on the asset type.

poster_image

  • original
  • thumbnail
  • preview
  • ld
  • sd
  • hd
  • xd
  • smallest
  • largest

poster_video

  • original
  • thumbnail
  • preview
  • default
  • ld
  • sd
  • hd
  • xd
  • smallest
  • largest

panosphere_image

  • original
  • thumbnail
  • preview
  • base (greyscale)
  • ld
  • sd
  • hd
  • xd
  • smallest
  • largest

panosphere_video

  • thumbnail
  • preview
  • original
  • ld
  • sd
  • hd
  • xd
  • smallest
  • largest

model_obj

  • original
  • model
  • material

animated_model_fbx

  • original
  • model

sound_obj / action_sound / background_sound

  • original
  • audio

shape_box / shape_ball / shape_tube / shape_pyramid / shape_diamond / shape_donut

  • original
  • thumbnail
  • preview
  • ld
  • sd
  • hd
  • xd

target_image

  • original
  • thumbnail
  • default

app_image

  • original

favicon

  • original
  • 16x16
  • 32x32
  • android-96x96
  • android-192x192
  • apple-57x57
  • apple-60x60
  • apple-72x72
  • apple-76x76
  • apple-114x114
  • apple-120x120
  • apple-144x144
  • apple-152x152
  • apple-180x180

url_type

If url_type is not defined or is set to cdn then you will get back a URL that points directly to the CDN, which gives you the fastest delivery.

If url_type is set to app then you get back a URL that is relative to your app host. app URLs will be redirected to the CDN URL by the app server, but are useful if you want to use a persistent URL that can be used within HTML or CSS.

However, if you use app URLs for videos and then try to use this redirected video within your 3D scene you may find iOS refuses to render this as a texture and throws a SecurityError warning. This is an iOS bug from 2012 and seems unlikely to be fixed.

fallback_to_original

fallback_to_original is an optional boolean flag that defaults to true. If true and the file_type you request is not available then the original file uploaded for this asset will be returned if that is available.

Please see the console warnings for various file_types as they may or may not be usable within the browser (e.g. 3D models originally uploaded as .zip files).