FitVids.js

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

  • Owner: davatron5000/FitVids.js
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

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

* 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.

Main metrics

Overview
Name With Ownerdavatron5000/FitVids.js
Primary LanguageHTML
Program languageJavaScript (Language Count: 2)
Platform
License:
所有者活动
Created At2011-09-01 22:06:04
Pushed At2022-05-06 07:42:30
Last Commit At2017-01-27 11:47:46
Release Count5
Last Release Namev1.2.0 (Posted on )
First Release Namev1.0.1 (Posted on 2014-02-28 07:47:08)
用户参与
Stargazers Count4.8k
Watchers Count174
Fork Count1k
Commits Count95
Has Issues Enabled
Issues Count198
Issue Open Count25
Pull Requests Count31
Pull Requests Open Count12
Pull Requests Close Count29
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private