Currently in both 7.x-2.3 and 7.x-3.x the following code is present in the videojs.tpl.php file:
print check_plain(file_create_url($item['uri']))
I believe that this processing should be done within the theme function rather than the tpl file and a new element should be added to the item array, something along the lines of:
$item['src'] = array('raw' => file_create_url($item['uri']), 'safe' => check_plain(file_create_url($item['uri']));
The template file would then look something like this (note that I have changed the $item['videotype'] code too; this change should be applied to any processing currently done in the tpl, not just the video uri):
<source src="<?php print $item['src']['safe']; ?>" type="<?php print $item['videotype']['safe'] ?>" />
This would tidy up the tpl file while still giving the user the option of accessing the other variables such as $item['uri']. The main benefit however would be that other modules could override the variable through theme override functions without having to reproduce the tpl file itself.
For a bit of background, I'm currently writing a module that would allow Video.js to serve media stored in Drupal's private file system using one-time, unque, user specific source URLs. At the minute, no matter the approach I use I'm still going to have to reproduce the tpl file somewhere in order to change the code I initially mentioned. Ideally, if this processing was done in the theme function I could override any variables I wanted in my module without having to touch a tpl file.
Comment | File | Size | Author |
---|---|---|---|
#6 | videojs-remove-file_create_url-2069865-1.patch | 3.62 KB | jamiehollern |
#3 | videojs-remove-file_create_url-2069865-1.patch | 3.62 KB | jamiehollern |
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedYour code snippets look fine, although I think it is nicer to rewrite it such that file_create_url() is just called once. Could you make a patch for it? I will commit it to 7.x-3.x, so please use that branch as your base version.
Comment #2
jamiehollernNo problem, I'll get a patch done in the next day or two for version 7.x-3.x.
Edit to say that I agree with your point regarding file_create_url, obviously the code was just used as an example. I'll make sure it's as efficient as possible.
Comment #3
jamiehollernHere's the patch as promised. I've tested it and it seems to work fine. One thing to note is that I've left some of the "tracks" stuff alone as I wasn't exactly sure how it worked. For example:
print check_plain($track['kind'])
print check_plain($track['label'])
print check_plain($track['langcode'])
Comment #4
jamiehollernComment #6
jamiehollernIt seems the patch failed because I forgot to change the version. Trying again.
Comment #7
jamiehollernDuplicate.
Comment #8
Jorrit CreditAttribution: Jorrit commentedCommitted, thanks!