function media_browser_build_media_item in D7 Media 7.4
Same name and namespace in other branches
- 7 includes/media.browser.inc \media_browser_build_media_item()
- 7.2 includes/media.browser.inc \media_browser_build_media_item()
- 7.3 includes/media.browser.inc \media_browser_build_media_item()
Adds additional properties to a file which are needed by the browser JS code.
Parameters
object $file: A Drupal file object.
2 calls to media_browser_build_media_item()
- media_browser in includes/
media.browser.inc - Media browser page callback.
- template_preprocess_media_views_view_media_browser in ./
media.views.inc - Display the view as a media browser.
File
- includes/
media.browser.inc, line 250 - Summon plugins and render the media browser.
Code
function media_browser_build_media_item($file, $view_mode = 'preview') {
$preview = media_get_thumbnail_preview($file, NULL, $view_mode);
$file->preview = drupal_render($preview);
$file->url = file_create_url($file->uri);
// Support absolute / relative urls.
if (variable_get('media_browser_relative_url', FALSE)) {
$tmp_scheme;
$tmp_host;
$tmp_port;
$tmp_base_url;
$parse_tmp = parse_url($file->url);
$tmp_scheme = $parse_tmp['scheme'];
$tmp_host = $parse_tmp['host'];
if (isset($parse_tmp['port'])) {
$tmp_port = $parse_tmp['port'];
$tmp_base_url = $tmp_scheme . '://' . $tmp_host . ':' . $tmp_port;
}
else {
$tmp_base_url = $tmp_scheme . '://' . $tmp_host;
}
$file->url = substr($file->url, strlen($tmp_base_url));
}
}