Closed (fixed)
Project:
jPlayer
Version:
7.x-2.x-dev
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Reporter:
Created:
2 Nov 2011 at 00:07 UTC
Updated:
17 Jun 2015 at 14:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ywarnier commentedWith the attached patch, the module checks for the existence of a jplayer.js and a jplayer.css file in the theme/[yourtheme]/jplayer/ directory. If the files are there, it loads them from there. Otherwise, it loads them from the module's theme/ directory.
This allows for the clean customization of both the behaviour and the appearance of the player without modifying the module. Please review and submit. I don't mind submitting myself if you give me maintainer access (check my profile, I'm already doing it for a pair of other modules).
Comment #2
rlmumfordDo this do themes that are in sites/all/themes? As this is the standard place to put Drupal Themes?
Comment #3
webadpro commentedWould it be possible to apply these patches to the git, please?
Comment #4
nikosnikos commentedThere's another solution. No patch needed (except for THEMING.txt).
Override jplayer.css
In your theme, add
MYTHEME_preprocess_jplayerfunction totemplate.phpand and the CSS you want for jplayer.Here's what it looks like :
The two important things are that :
jplayer.cssif you want to replace the CSS of the jplayer module.In my opinion this is more complicated than just add a CSS to your theme but the advantages are that :
Override jplayer.js
For JS this is a little bit more complicated. If you just want to add some JS to the defaults, you just have to add this to your
template.php:But if you want to replace the default JS module file, you'll have to alter the js in your
template.phptoo :Unlike
drupal_add_css,drupal_add_jswon't replace jplayer.js even if this is the same name than the module default JS.Comment #5
nikosnikos commentedAnother simplest solution ;)
Case 1: I want to replace the jplayer CSS and/or JS by my own
I replace
$variables['dynamic']['#attached']['css']and/or$variables['dynamic']['#attached']['js']by mine intemplate.php.Case 2: I want to add my own CSS or JS to jplayer's one
I add my JS and/or CSS with
drupal_add_jsanddrupal_add_cssdrupal functions intemplate.php. Attention: CSS file name MUST be different than "jplayer.css" used by the module otherwise it will replace the module CSS file.Comment #6
j0rd commentedI've noticed that the D7 version ins't skinnable as per instructions. This patch appears to resolve my problem.
This needs to get committed, or the documentation needs to get changed to say "You can't skin this currently with out hacking the module" :D
Comment #7
deviantintegral commentedI don't think the patch in #1 is required, though the documentation should be updated. To add CSS and JS, you need to modify your theme's info file:
https://drupal.org/node/263967
https://drupal.org/node/171213
To replace JavaScript code, you add your JS file in the info file, and reassign Drupal.behaviors.* as required.
How does this look for a docs update?
Comment #8
deviantintegral commentedComment #9
Orbite commentedIn 'overriding css theme' i don't understand where i put the css of custom theme. Can i create more theme folder for each css file?
For exemple:
css/theme_1/jplayer.css
css/theme_2/jplayer.css
css/theme_3/jplayer.css
In this mode is it possible switch the module theme for each view? I would like to decide the theme for teaser and full content.
Thanks for your ideas!
Comment #10
webadpro commentedI personally think, having the option into the display formatter would suit us all better and leave more options to the user depending on the view.
I would suggest placing all the themes into sites/all/libraries/jplayer/themes/yourthemes
And the display formatter would be looking for the themes at that location, and would allow you to use the jplayer themes in different themes of your sites rather than having to code everything for each themes you have.
Comment #11
Orbite commented+1 !
Comment #12
ebeyrent commentedI wasn't able to get these suggestions to work for my Omega 7.x-3.x subtheme. What did work for me:
1. Copy jplayer custom css and images into a folder in my theme, i.e MYTHEME/jplayer/myskin
2. Copy region--content.tpl into your custom theme
3. In MYTHEME/preprocess/preprocess-page.inc, add:
Comment #13
digitalfrontiersmediaWhile nikosnikos solution #5 works, if I simply want to add additional CSS or JS to override things in jplayer, this is fairly standard practice.
But to outright override the js file, for example, by replacement shouldn't require a bunch of programming instructions in the README, and in my opinion simply pointing them to http://drupal.org/node/171213 per deviantintegral is a cop-out. We want Drupal to be less obtuse--not more--to foster adoption.
The original thinking behind the README for how an override should work I think is sound and the best overall solution, and ywarnier has already offered that solution. I agree with j0rd. ywarnier's patch works as described and intended and should be committed.
If there were to be a change to ywarnier's patch, I would agree with webadpro in comment #10.
Otherwise, please commit.
Comment #14
deviantintegral commentedThe issue I have with the patch in #1 is that it provides a different method for doing the formatter theming than most other field modules, and what core itself does. It might seem simpler for this module itself, but then all of that process has to be thrown out when theming some other field provided by some other module.
I think there are two cases:
If there are other modules in widespread use that I'm not aware of, and are doing something similar to what's proposed in #1 and #10, and placing display formatter CSS in a common theme or library directory, I'd be OK with committing a solution along those lines. Let's just make sure we're not implementing a one-off solution.
Comment #15
webthingee commentedPatch to Documentation, that adds some detail and points to support documentation for how to override the css and js files.
!code raid
~webthingee
Comment #16
deviantintegral commentedI reworked the patch to wrap at 80 lines as well as fix some minor style issues. It's committed as 665eb1a.
Comment #18
dan.mantyla commentedI don't think this was ever committed and it looks like the patch is too late for 2.0-beta1 as the function has changed. Also, solution #5 did not work for me.
If I can find the time maybe I'll write a patch.
Comment #19
dan.mantyla commentedThe documentation patch #15did help. Please add this.
Comment #20
tostinni commented@deviantintegral i saw the documentation patch applied but when I declare my custom jplayer.js in my theme.info, the page then load 2 jplayer.js (my custom one is loaded first, and then the jplayer.js from the module which loads in the footer).
As the original jplayer.js is loaded last it isn't overrided.
What would be the solution to avoid this situation ? Thank you.
Comment #23
markie commentedClosing as this has been committed. Thanks