You are here

function asset_render in Asset 5.2

Central asset rendering function.

Parameters

$asset : The asset to be rendered

$format : Can be either a full array of formatting options (like that returned from asset_get_macros() or a string specifying the formatter to use

Related topics

3 calls to asset_render()
asset_emfield_asset_type in contrib/asset_emfield/asset_emfield.module
Implementation of hook_asset_type().
asset_field_formatter in modules/asset_content.inc
Implementation of hook_field_formatter().
asset_render_macro in ./asset.module
build html from atrributes array.

File

./asset.module, line 618
Main module.

Code

function asset_render($asset, $format = NULL) {
  if (is_array($format)) {
    $attr = $format;
    $format = $attr['format'];
  }
  else {
    $attr = array(
      'format' => $format,
    );
  }
  if (in_array($format, array_keys($asset->formatters))) {
    $format = $asset->formatters[$format];
    $output = module_invoke($format->module, 'asset_formatter', 'render', $asset, $attr);
    $attr['display'] = $attr['display'] ? $attr['display'] : $format->display;
    return theme('asset', $output, $attr);
  }
  else {
    return 'n/a';
  }
}