function media_get_file_without_label in D7 Media 7
Returns a drupal_render() array for just the file portion of a file entity.
Optional custom settings can override how the file is displayed.
2 calls to media_get_file_without_label()
- media_format_form in includes/
media.filter.inc - Form callback used when embedding media.
- media_token_to_markup in includes/
media.filter.inc - Replace callback to convert a media file tag into HTML markup.
File
- includes/
media.filter.inc, line 611 - Functions related to the WYSIWYG editor and the media input filter.
Code
function media_get_file_without_label($file, $view_mode, $settings = array()) {
$file->override = $settings;
// Legacy support for Styles module plugins that expect overridden HTML
// attributes in $file->override rather than $file->override['attributes'].
if (isset($settings['attributes'])) {
$file->override += $settings['attributes'];
}
$element = file_view_file($file, $view_mode);
// The formatter invoked by file_view_file() can use $file->override to
// customize the returned render array to match the requested settings. To
// support simple formatters that don't do this, set the element attributes to
// what was requested, but not if the formatter applied its own logic for
// element attributes.
if (!isset($element['#attributes']) && isset($settings['attributes'])) {
$element['#attributes'] = $settings['attributes'];
// While this function may be called for any file type, images are a common
// use-case. theme_image() and theme_image_style() require the 'alt'
// attribute to be passed separately from the 'attributes' array (see
// http://drupal.org/node/999338). Until that's fixed, implement this
// special-case logic. Image formatters using other theme functions are
// responsible for their own 'alt' attribute handling. See
// theme_media_formatter_large_icon() for an example.
if (isset($settings['attributes']['alt']) && !isset($element['#alt']) && isset($element['#theme']) && in_array($element['#theme'], array(
'image',
'image_style',
))) {
$element['#alt'] = $settings['attributes']['alt'];
}
}
return $element;
}