A lightweight, easy-to-use jQuery plugin for fluid width video embeds.

Overview

Introducing FitVids.js

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.

FitVids automates the Intrinsic Ratio Method by Thierry Koblentz to achieve fluid width videos in your responsive web design.

How Do I Use It?

Include jQuery 1.7+ and FitVids.js in your layout and target your videos container with fitVids().

<script src="path/to/jquery.min.js"></script>
<script src="path/to/jquery.fitvids.js"></script>
<script>
  $(document).ready(function(){
    // Target your .container, .wrapper, .post, etc.
    $("#thing-with-videos").fitVids();
  });
</script>

This will wrap each video in a div.fluid-width-video-wrapper and apply the necessary CSS. After the initial Javascript call, it's all percentage-based CSS magic.

Currently Supported Players

YouTube Y
Vimeo Y
Blip.tv Y*
Viddler Y*
Kickstarter Y*

* means native support for these may be deprecated. If your video platform is not currently supported, try adding it via a customSelector...

Add Your Own Video Vendor

Have a custom video player? We now have a customSelector option where you can add your own specific video vendor selector (mileage may vary depending on vendor and fluidity of player):

  $("#thing-with-videos").fitVids({ customSelector: "iframe[src^='http://mycoolvideosite.com'], iframe[src^='http://myviiids.com']"});
  // Selectors are comma separated, just like CSS

Note: This will be the quickest way to add your own custom vendor as well as test your player's compatibility with FitVids.

Ignore With Class

Have a video you want FitVids to ignore? You can slap a class of fitvidsignore on your object or container and your video will be displayed as it is defined.

If you'd like to add a custom block to ignore FitVids, use the ignore option.

  $("#thing-with-videos").fitVids({ ignore: '.mycooldiv, #myviiid'});
  // Selectors are comma separated, just like CSS

Target Videos embedded without classes or containers

Customers/clients will occasionally add a video to a general content area or article and this may be without a class or container that you're targetting. A solution to this is to target the parent of videos, using something like the below;

  $('iframe[src*="youtube"]').parent().fitVids();
  // You can change the selector to suit potential video providers, or chain them if your customer is likely to use more than one provider

By targetting the iframe/embed parent you can then dynamically add in the fitVids special sauce on the fly without needing to know the container ahead of time.

Known issues

  • Vimeo Autoplay API is not compatible with FitVids in IE11. You must manually wrap videos you want to autoplay.
Comments
  • Chrome back navigation replaces all frames

    Chrome back navigation replaces all frames

    It's become apparent to me that when in Google Chrome (37), if I navigate away from a page that has multiple FitVids instances, and then use the browser's back button to return to the page, all of the frames become the same frame (even though they still contain the original markup).

    There is an open Chromium bug for this: https://code.google.com/p/chromium/issues/detail?id=395791

    As a temporary fix I have done the following:

    $allVideos.each(function(){
        ...
        // Reload iFrame to fix Chrome bug
        $this.attr('src', $this.attr('src'));
    });
    

    I know it seems silly to have to reset the same source, but it does work. Is there a more permanent fix for this coming down the line, or are we going to hold out until Google fixes the issue with Chrome? It's been there since at least v34 and is still on v37.

    opened by jodyheavener 24
  • IE9 errors

    IE9 errors

    Someone posted a comment on my blog. My IE9 test environment is totally bjorked so I can't confirm or deny.

    Causes bizarre errors for me in IE9 when using youtube's iframe embeds (though it really looks like a problem with their code, not fitvids directly). Claims "Math is not defined." May have something to do with the floating point dimensions and YT's iframe resize code.

    Here's a fiddle:
    http://jsfiddle.net/YnFsn/

    Looking into it, but you may have more insight. Works like a charm with all other browsers: brilliant stuff.
    Bug 
    opened by davatron5000 22
  • Social Cam

    Social Cam

    Love this!

    Any chance of getting it to work with http://socialcam.com/?

    ie.

    <iframe width="520px" height="391px" src="http://socialcam.com/videos/XRMP3Y5t/embed?utm_campaign=web&utm_source=embed" frameborder="0" allowfullscreen></iframe>
    
    opened by Toledoh 20
  • iFrame Embed Swapping/Duplicating

    iFrame Embed Swapping/Duplicating

    Recently we started noticing an issue with FitVids where it will cause all the iFrame embeds on the page to swap out for one of the random embeds duplicating the video across the page. In testing we can reproduce this 100% of the time in the latest versions of Chrome (16.0.912.77) and Safari (5.1.2). Oddly Firefox 6 & 8 do not have the issue, but Firefox 3.6 behaves the same way.

    jsFiddle - http://jsfiddle.net/nAXXY/5/ Five embeds (Vimeo and Youtube), simple CSS, jQuery 1.7.1 and latest FitVids.js

    Steps to reproduce:

    1. Load up http://jsfiddle.net/nAXXY/5/
    2. Click on any link taking you to a new page or type in a new URL
    3. Hit back on your browser
    4. Refreshing the page will correct the issue

    Video demo - http://cloud.jonathanmoore.com/Ddsv

    Critical 
    opened by jonathanmoore 18
  • Not working with Blip.tv...?

    Not working with Blip.tv...?

    On the readme it says Fitvids works with Blip.tv, but look here:

    http://jsbin.com/ejazuf/1/edit

    Notice the video wrapper that's supposed to be placed around the video by the script is actually appearing below the video, creating a big gap between the video and the links (which should be right under the video).

    Has anyone seen this bug before? I didn't investigate it too much but I also couldn't find any issues discussing blip.tv on here.

    Bug 
    opened by impressivewebs 13
  • Video breaks from container on Orientation change??

    Video breaks from container on Orientation change??

    Hi,

    Have a wee problem with FitVids, where the video breaks from it's container when the orientation is changed on a Smartphone.

    Preview site can be viewed here - www.contrast.firstbasedesign.co.uk

    It will load up fine in Portrait. But if you switch to Landscape mode, then back to portrait, the video keeps the dimensions from Landscape mode??

    Hmmm

    opened by firstbasedesign 13
  • Support for kaltura

    Support for kaltura

    I've been trying to get fitvids to work with my kaltura player ( http://kaltura.org ) but just can't seem to get it to work.

    Here is a 'temp' video embed code to test:

    https://gist.github.com/2325974

    I tried to paste in the embed code here, but it just doesn't work, hence the gist.

    Basically I have to modify the fitvids.js script to force a fixed height, which of course breaks the entire concept of fitvids.

    Is there an easy fix for this?

    opened by anointed 12
  • Using FitVids in a JavaScript Slider

    Using FitVids in a JavaScript Slider

    Hi davatron,

    Firstly, thanks for the awesome jQuery plugin. It really is a great asset to have in one's library.

    We've implemented FitVids.js in addition to a featured slider, namely FlexSlider ( http://flex.madebymufffin.com/ ). Upon doing so, we noted that FitVids.js had issues retrieving the width and height information for Vimeo videos embedded with an iFrame. We modified our script to force a width and height attribute for this iframe, with the result that a black poster frame displays for the video, but no video controls display on hover of this video.

    Hoping this is a known issue that can be resolved.

    Thanks again for the great plugin. :)

    Thanks and regards, Matty.

    opened by mattyza 12
  • Windows 7 64 bits + Firefox 13.0.1 + Flash 11.3.300.257 + Youtube video = Fail.

    Windows 7 64 bits + Firefox 13.0.1 + Flash 11.3.300.257 + Youtube video = Fail.

    OH HAI. I'm using the following configurations :

    • Windows 7 SP1 64 bits + Firefox 13.0.1 + Flash 11.3.300.257
    • Windows Vista (sorry) Pro 32 bits + Firefox 13.0.1 + Flash 11.3.300.257

    On the first one, the window can't be resized (so the video can't too). It works well on the other one.

    Weird thing 1 : maximazing the window resizes the video ! Weird thing 2 : the video adapts to the original window size, but resizing isn't allowed once it is loaded.

    Any idea ?

    Thanks !

    opened by SiegfriedEhret 11
  • mobile safari: vimeo embed not properly resized in portrait view

    mobile safari: vimeo embed not properly resized in portrait view

    Fitvids rocks!

    I'm using the fitvids wordpress plugin. The most recent version of the plugin and of wordpress.

    When viewing my site in mobile safari, and loading the page in portrait view, I'm finding that vimeo embeds do not properly resize. They exceed the width of the content area. Youtube seems to be working fine. Here's a screenshot comparing youtube and vimeo:

    vimeo-fitvids

    Here's the live page: http://www.vtbarfoundation.org/news/fitvids-test

    Everything works fine on a desktop browser, it just seems to be an issue with mobile safari.

    I realize you request reduced test cases for troubleshooting, but I wasn't sure how to do that in this case as it may be an issue with the plugin itself. Best I could think to do was to create a specific post containing embeds from both youtube and vimeo.

    Thanks in advance for any help, and for all your great work!

    Bug 
    opened by dadra 10
  • Positioning Issue

    Positioning Issue

    I'm having an issue with absolute positioning. It looks like the video object inside my fluid-width-video-wrapper is being positioned absolutely, but the wrapper isn't getting any type of dimensions applied to it which is causing my video to cover the content that comes after it.

    Could it be related to the fact that the page contains user generated content, and the user submitted a YouTube embed with height and width attributes on it?

    I'm seeing this in Safari 5.2 and 5.1. Are there any known fixes for this?

    opened by andrewlphilpott 10
  • When I try to use this library is react + typescript then " error comes">

    When I try to use this library is react + typescript then "Property 'fitVids' does not exist on type 'JQuery" error comes

    Hi Folks, When I try to use this library with react + typescipt then below error comes : Property 'fitVids' does not exist on type 'JQuery'

    Any guesses what could be the reason ? I think of types may be. Please guide.

    opened by bhavikg-dev 0
  • Support youtu.be domain name

    Support youtu.be domain name

    Apparently the script doesn't work when using the YouTube short URL format, which use the youtu.be domain name instead of youtube.com.

    I haven't tested extensively, but as far as I can tell, simply adding this domain in the script (line 37) does the trick:

    return this.each(function(){
      var selectors = [
        'iframe[src*="player.vimeo.com"]',
        'iframe[src*="youtu.be"]',
        'iframe[src*="youtube.com"]',
        'iframe[src*="youtube-nocookie.com"]',
        'iframe[src*="kickstarter.com"][src*="video.html"]',
        'object',
        'embed'
      ];
    
    opened by s427 0
  • Please add a license to your code!

    Please add a license to your code!

    Please kindly add a license to your code. We are not able to use your code in our open-source project because it does not have a license. Your help will be much appreciated.

    opened by LabinatorSolutions 2
  • fitvids with AJAX call?

    fitvids with AJAX call?

    Hi,

    I'm having some issues with Fitvids.

    1. I kept calling it fitbit for some reasons.
    2. I'm currently running a wordpress theme (Caos), which implements AJAX calls through REST API , and Fitvids won't run unless I disable that AJAX call.

    Is there a way to call Fitvids after the contents been loaded?

    No Example Code Needs Information 
    opened by randomwahaha 1
  • parseInt causes 100% width to evaluate to 100, breaking aspect ratios

    parseInt causes 100% width to evaluate to 100, breaking aspect ratios

    https://codepen.io/johnnyquest/pen/KKpQYLp

    Related pull request: https://github.com/davatron5000/FitVids.js/pull/245

    Has any progress been made on this?

    As an aside, comment block at the top of the main js file is tagged as 1.1 rather than 1.2. Causes a little confusion.

    opened by JohnnyQuest1983 0
Owner
Dave Rupert
Lead developer at Paravel. Purveyor of tiny jQueries.
Dave Rupert
One-click embeds for all your links posts, mirrors & comments.

Lens Embeds One-click embeds for all your links posts, mirrors & comments. Getting Started First, install dependencies with yarn install. Then, run th

Miguel Piedrafita 12 Sep 7, 2022
Discord-Bot - You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have published on my youtube channel.

Discord-Bot You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have publishe

Umut Bayraktar 114 Jan 3, 2023
Video.js - open source HTML5 & Flash video player

Video.js - HTML5 Video Player Video.js is a web video player built from the ground up for an HTML5 world. It supports HTML5 video and Media Source Ext

Video.js 34.8k Jan 5, 2023
A Node JS Express/Serverless demo application that creates a slideshow video using the Pexels image library and Shotstack video editing API.

Shotstack Pexels Slideshow Video Demo This project demonstrates how to use the Shotstack cloud video editing API to create a video using an HTML form

Shotstack 25 Dec 9, 2022
A Chrome extension to help you inspect Mp4 video content and find irregularities in video streams.

MP4Inspector A Chrome extension to help you inspect Mp4 video content and find irregularities in video streams. Installation In chrome navigate to chr

Bitmovin 48 Nov 28, 2022
A lightweight easy-to-use minecraft chatbridge

Kyuta Bot - Minecraft ChatBridge Kyuta is discord chat-bridge integration for minecraft based on the bedrock-protocol library and functions similarly

Sierrawastaken 7 Sep 27, 2022
Flexible and easy Dash/HLS/DRM integration for HTML5 video.

This project is made possible with Plyr, Hls.js, Dash.js. Features ?? HLS and DASH playback ?? Multi quality supported ?? Drm with custom header suppo

Tuhin Kanti Pal 25 Nov 11, 2022
jPlayer : HTML5 Audio & Video for jQuery

jPlayer : HTML5 Audio & Video for jQuery Gitter Support for Zepto 1.0+ compiled with the data module. What is jPlayer? jPlayer is a jQuery/Zepto plugi

jPlayer 4.6k Dec 27, 2022
▶️ Deskreen Youtube channel (video tutorials, demos, use cases for Deskreen day to day usage)

▶️ Deskreen Youtube channel (video tutorials, demos, use cases for Deskreen day to day usage)

Leo 2 Jan 31, 2022
Easy and simple twitch bot in node.js.. very very easy..

How It Works identity: { username: 'YOUR BOTS USERNAME', <-- This is where you place the username that you gave the bot account password: '

Ventispurr 3 Dec 18, 2021
An Easy to use and advanced working multiguild Waitingroom Bot written in discord.js v13 without any extra modules.

Multiguild-Waitingroom-v13 An Easy to use and advanced working multiguild Waitingroom Bot written in discord.js v13 without any extra modules. It is m

Tomato6966 17 Dec 11, 2022
Easy-to-use , actively maintained discord bot written in dJS V13 with customizable features

Multi-purpose discord bot Found a bug? Notes There are some modules missing, you can still start the bot but there are some things within the source t

locus 7 Nov 28, 2022
A simple and easy-to-use WhatsApp bot project based on Multi-Device Baileys and written in JavaScript

MIZUHARA ANIME THEMED FULL FLEDGED MULTI DEVICE WHATSAPP BOT WITH COOL FEATURES A Full Fledged MD Bot For Bot Lovers REQUIREMENTS • HOW TO INSTALL? •

Arus~Bots 18 Oct 25, 2022
LazyLoad Embed YouTube Player - simple and lightweight plugin - pure JavaScript

Youtube LazyLoad LazyLoad Embed Youtube Player - simple and lightweight plugin - pure JavaScript Status View Preview Table of contents Status Quick St

The MUDA Organization 25 Nov 29, 2022
LazyLoad Embed Vimeo Player - simple and lightweight plugin - pure JavaScript

Vimeo LazyLoad LazyLoad Embed Vimeo Player - simple and lightweight plugin - pure JavaScript Status View Preview Table of contents Status Quick Start

The MUDA Organization 23 Nov 3, 2022
Enables

HTML5 video made easy All it takes is a single line of code to make HTML5 video and audio tags work in all major browsers. How to enable video and aud

Dave Hall 1.3k Dec 17, 2022
The HTML5 video player for the web

Flowplayer website | demos | docs For the impatient Download Flowplayer Unzip Drop the folder under your server Minimal setup <!DOCTYPE html> <head>

Flowplayer 1.9k Dec 30, 2022
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Dec 27, 2022
HTML5

One file. Any browser. Same UI. Author: John Dyer http://j.hn/ Website: http://mediaelementjs.com/ License: MIT Meaning: Use everywhere, keep copyrigh

MediaElement.js 8k Jan 8, 2023