Hi,
I'm using videojs with theme() function (see readme of videojs).
All is working good except for poster :
In videojs.theme.inc
file, inside videojs_preprocess_videojs()
function we can see
...
// Add the defaults to $vars['attributes'] and merge with $vars.
$options = videojs_utility::getDisplaySettings($vars['attributes']);
$vars = array_merge($vars, $options);
$vars['items'] = array();
$vars['tracks'] = array();
$vars['poster'] = NULL;
...
then after we can see
...
// Turn the poster image URI into a URL, if it isn't an URL already.
if (!empty($vars['poster']) && strncmp($vars['poster'], 'http://', 7) !== 0 && strncmp($vars['poster'], 'https://', 8) !== 0) {
if (empty($vars['posterimage_style'])) {
$vars['poster'] = file_create_url($vars['poster']);
}
else {
$vars['poster'] = image_style_url($vars['posterimage_style'], $vars['poster']);
}
}
...
That mean test condition is never reached ! So never output poster because of $vars['poster']
is always null
My working fix :
I filled a "poster" key inside $vars['attributes']
array (because poster is outputted as an attribute :)) before calling theme('videojs', $items)
Then I changed reference to $vars['poster']
with $vars['attributes']['poster']
(so $vars['poster'] is passed to template, with correct uri)
like that
// Turn the poster image URI into a URL, if it isn't an URL already.
if (!empty($vars['attributes']['poster']) && strncmp($vars['attributes']['poster'], 'http://', 7) !== 0 && strncmp($vars['attributes']['poster'], 'https://', 8) !== 0) {
if (empty($vars['posterimage_style'])) {
$vars['poster'] = file_create_url($vars['attributes']['poster']);
}
else {
$vars['poster'] = image_style_url($vars['posterimage_style'], $vars['attributes']['poster']);
}
}
What do you think about this ? Dis I missed something ?
Thanks
Comments
Comment #1
rroblik CreditAttribution: rroblik commentedtypo
Comment #2
dkingofpa CreditAttribution: dkingofpa commented$vars['poster'] is set within the foreach block.
You can add a poster image by implementing hook_preprocess_videojs() in a module. Here's some psuedo-code for doing this...
The "Example" section in the module's README.md can also provide more details about the structure passed to the theme function.