function theme_media_soundcloud_embed in Media: SoundCloud 7
@todo: get this working
This code is for embedding audios in WYSIYWG areas, not currently working. NOTE: Deprecated with Styles version 2.
2 theme calls to theme_media_soundcloud_embed()
- theme_media_soundcloud_field_formatter_styles in includes/
themes/ media_soundcloud.theme.inc - theme_media_soundcloud_styles in includes/
themes/ media_soundcloud.theme.inc - NOTE: Deprecated with Styles version 2.
File
- includes/
themes/ media_soundcloud.theme.inc, line 99 - media_soundcloud/includes/themes/media_soundcloud.theme.inc
Code
function theme_media_soundcloud_embed($variables) {
//drupal_set_message("theme_media_soundcloud_embed");
$preset_name = $variables['preset_name'];
$preset = styles_containers_available_styles('file', 'media_soundcloud', $preset_name);
$output = '';
if (!empty($preset)) {
// Build the URL for display.
$uri = $variables['uri'];
$wrapper = file_stream_wrapper_get_instance_by_uri($uri);
$parts = $wrapper
->get_parameters();
$in_browser = $thumbnail = FALSE;
foreach ($preset['effects'] as $effect) {
switch ($effect['name']) {
case 'autoplay':
$autoplay = $effect['data']['autoplay'] ? 'true' : 'false';
break;
case 'resize':
$width = $effect['data']['width'];
break;
case 'thumbnail':
$thumbnail = $effect['data']['thumbnail'];
}
}
if (isset($variables['object']->override)) {
$override = $variables['object']->override;
if (isset($override['width'])) {
$width = $override['width'];
}
if (isset($override['wysiwyg'])) {
$thumbnail = TRUE;
}
if (isset($override['browser']) && $override['browser']) {
$in_browser = TRUE;
$thumbnail = TRUE;
}
}
$width = isset($width) ? $width : media_soundcloud_variable_get('width');
$user_name = check_plain($parts['u']);
$audio_name = check_plain($parts['a']);
if ($thumbnail) {
// @todo Clean this up.
$image_variables = array(
'path' => $wrapper
->getOriginalThumbnailPath(),
'alt' => $variables['alt'],
'title' => $variables['title'],
'getsize' => FALSE,
);
if (isset($preset['image_style'])) {
$image_variables['path'] = $wrapper
->getLocalThumbnailPath();
$image_variables['style_name'] = $preset['image_style'];
$output = theme('image_style', $image_variables);
}
else {
// We need to add this style attribute here so that it doesn't get lost
// If you resize a audio in a node, save it, edit it, but don't adjust
// the sizing of the audio while editing, the size will revert to the
// default. Adding the specific size here retains the original resizing
$WYSIWYG = isset($variables['object']->override['style']) ? $variables['object']->override['style'] : '';
$image_variables['attributes'] = array(
'width' => $width,
'style' => $WYSIWYG,
);
$output = theme('image', $image_variables);
}
if ($in_browser) {
// Add an overlay that says 'SoundCloud' to media library browser thumbnails.
$output .= '<span />';
}
}
else {
$output = theme('media_soundcloud_audio', array(
'uri' => $uri,
'width' => $width,
'autoplay' => $autoplay == 'true' ? TRUE : NULL,
));
}
}
return $output;
}