#103: Integrating FitVids.js into WordPress
The default WordPress theme at the time of this screencast is TwentyEleven, a wonderfully simple and responsive design. That is, until we post an awesome YouTube video as a new blog post and the responsiveness breaks down. The video doesn't fill the area on wide screens and is too big on narrow screens, breaking outside the content area.
In this video we'll cover how to add jQuery to a WordPress theme, then download the jQuery plugin FitVids.js and integrate it into the theme (simple stuff!). The result is the video instantly fits the responsive nature of the theme. It works for video from any source.
Even though this is a simple and specific example, I hope it helps you understand how you can get started integrating any cool JavaScript thingy you find on the web into a WordPress site.
Links from the video:
- Awesome Video
- WordPress / TwentyEleven
- jQuery / ScriptSrc
- Enqueue Google-Hosted jQuery in a WordPress Theme
- FitVids.js / Intrinsic Ratios for Video
Running Time: 20:58
First line: “I have prepared for this zero” – love it Chris
Awesome video as usual, Chris!
One thing I’d point out to people: If you’re going to do this with the 2011 theme, make sure to copy/duplicate the theme first. Otherwise, if you update the theme later on, all of your changes will be lost.
Also, you can change that functions.php jQuery loader script to load jQuery in the footer by changing the last parameter to “true”, which tells the enqueue_script to load in the footer at wp_footer();
Thanks for sharing. This is gonna help tons!
I always learn (and laugh a bit) while watching your tutorials.
Very nice. Thank you.
Did miss the ‘bye’ at the end though :)
Awesome this came just in time! I am going to merge this into this Bones theme I found and give it a test run. Thank you Jacob for letting me know how to get this loaded in the footer!
Thanks for the screencast Chris. Here’s the code from the function.php file we used in a recent project. It’s basically doing the same thing you mentioned in the video but we are actually registering the script with WP for later use with the wp_enqueue_script function.
Also, if you don’t specify the last number of the jQuery version it will automatically pull the latest point version number for the mentioned version.
And as some already mentioned before, there’s the last variable in both the register and enqueue script function that will load the script in the footer.
Thought the extra jQuery file was an interesting idea...something I certainly will look into doing more.
You are my hero dude. Keep up the great work!
I don’t even use wordpress. I just watch this for the entertainment and pure brilliance. :) moar videoz!
Thank you so much, this is such a valuable tool, your video is also wonderful and entertaining! keep it up, I hope you enjoy much succes with any thing you do! keep rockin :D
Chris,
Thank you for your interesting tip & tutorial.
Could this be combined with the Screencast.com wordpress plugin?
https://wordpress.org/extend/plugins/screencastcom-video-embedder/
Is there an improvement opportunity by combining both plugins into one new plugin? Does this give you any new ideas to test? If so, please post a new screencast on this topic.
Thanks again!
LOL! Great video and made me style. You are talented to get this stuff, figure it out and pass it on to other people.
I am ASP/ASP.NET developer for YEARS and absolutely love WordPress and JQuery. Just getting into WP Plugin Integration.
This video was helpful in knowing what to tweak and where to put files and get proper path references. You just made me a few hundred bucks this year.
Thank you!
*style = smile with your style.
Works Great! Thank you.
First time i have seen that WTFPL license.
Is this now included in WP3.3? It appears to already resize in 3.3. Maybe I’m doing something wrong or just got lucky.
I just upgraded and tested default theme and FitVids is still needed.
Thanks for the video. I’ve got fitvids.js installed and all scripts are loading as they should. The thing I’m trying to do differently is rather than put my Vimeo embed code into a post or a page, I’m hard coding it into index.php into a div where I want my video to live.
Does anyone know how to accomplish this? What will I need to do differently? (Unfortunately I can’t provide an example link as the site has yet to launch.)
Here’s what I’ve got so far:
And in index.php:
And for the CSS:
Thanks!!!
Well, despite having errors in my code above (iframe id=”video” amongst others I’m sure), the main problem is seems to be that fitvids.js was corrupt. I tested this by re-downloading the package on github, and then plugging in my remote jquery.fitvids.js path into the local tests.html file, and it stopped working. Dropped in a fresh fitvids.js copy remotely, and boom!
There’s a Plugin for that! You don’t want to touch your theme files? Go and get Kevin Dees’ Plugin in the Extend at http://wordpress.org/extend/plugins/fitvids-for-wordpress/
you made me laugh out loud with this post at least 3 times. thanks!
Thanks for making me choke on my apple. Oh yeah, and the tutorial too.
Hey Chris, how could you make a flash 360 panoramic file dynamic? And also an html5 panoramic?
Would you also use the fitvid script?
DigWP
A book and blog co-authored by Jeff Starr and myself about the World's most popular publishing platform.
Quotes on Design
Design, like Art, can be an elusive word to define and an awfully fun thing to have opinions about.
HTML-Ipsum
One-click copy to clipboard access to Lorem Ipsum text that comes wrapped in a variety of HTML.
Bookshelf
Hey Chris, what books do you recommend? These, young fertile mind, these.