- πΊπΈUnited States bluegeek9
Thank you for your contributions to this issue. As Drupal 7 has reached its End of Life and is no longer supported, we are closing this issue. We encourage you to upgrade to a supported version of Drupal.
Hi,
I have been developing JW Player module with other colleagues. As part of project architecture, we decided to make JW Player presentation layer , providing predefined presets, skins and other configurations. All this while allowing file and media modules to do the actual heavy lifting work of uploading videos etc.
Our intention is for JW Player to provide presets that are available to styles. This is where we have hit roadblock.
The current support for image styles with ability to define effects, crop etc is great, however when it comes to Videos, presentation of videos is much more complex with things like, what skin to use, aspect ratio of the video, if there needs to be a thumbnail image etc. I am using video as an example, the same thing applies to other asset types such as audio.
I would like to suggest abstraction of these and allow other modules such as JW Player to define how the display of videos are to be rendered via presets.
Below is how i would like to implement
function jw_player_styles_default_presets() {
$containers = array();
$presets = _jw_player_styles_presets();
return array(
'file' => array(
'containers' => array(
'media_youtube' => array(
'default preset' => 'linked_thumbnail',
'styles' => array(
'original' => array(
'default preset' => 'video',
),
'thumbnail' => array(
'default preset' => 'linked_thumbnail',
),
'square_thumbnail' => array(
'default preset' => 'linked_square_thumbnail',
),
'medium' => array(
'default preset' => 'linked_medium',
),
'large' => array(
'default preset' => 'large_video',
),
),
'presets' => array(
array(
'name' => $preset_name,
'settings' => $settings,
'render callback' => "_jw_player_render_video"
)
);
),
),
),
);
}
// Loop through and apply each effect.
foreach ($this->getEffects() as $effect) {
// What is the effect?
$effectName = $effect['name'];
if (isset($effect['render callback'])) {
$render_method = $effect['render callback'];
if (function_exists($render_method)) {
$this->setOutput($render_method($this, $effect));
}
}
else {
if ($effectName && in_array($effectName, $methods)) {
// Apply the effect with its settings.
$this->$effectName($effect['settings']);
}
else {
// Ouch. We have an invalid effect. Flag for bug reporting.
$variables = $this->getVariables();
$styleName = $variables['style']['name'];
watchdog('styles', 'Effect %effect_name not found for %style_name display formatter style of the %class_name class.', array('%effect_name' => $effectName, '%style_name' => $styleName, '%class_name' => $this->getClassName()), WATCHDOG_WARNING);
}
}
}
With the tiny changes to code as above, any module that wishes to use existing containers and add presentation presets can do so easily by providing a callback to render output.
Closed: outdated
2.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Thank you for your contributions to this issue. As Drupal 7 has reached its End of Life and is no longer supported, we are closing this issue. We encourage you to upgrade to a supported version of Drupal.