Prettier embeds for your YouTubes - with nice options like high-res preview images, advanced customization of embed options, and optional FitVids support.

Overview

PrettyEmbed.js

Prettier embeds for your YouTubes - with nice options like high-res preview images, advanced customization of embed options, and optional FitVids support.

PrettyEmbed.js on GitHub

PrettyEmbed.js Demo on CodePen

Features

  • Choose from one of eight thumbnail sizes
  • Implement programmatically or via HTML5 data- attributes

Getting Started

Requirements

There are two methods of implementing PrettyEmbed.js - an HTML5 driven method, and a script driven method.

  1. Include jQuery
  2. Include waitForImages
  3. On the document.ready() event, call the plugin

HTML5 Driven Application

Form embeds by attaching the class of .pretty-embed, as well as any other required data-pe- options.

<div class="pretty-embed" data-pe-videoid="aBcDeFg12345" data-pe-fitvids="true"></div>

Call the plugin

$().prettyEmbed({ useFitVids: true });

Script Driven

Create an HTML placeholder, such as this:

<div id="my-video-display"></div>

Call the plugin on the placeholder element:

$('#my-video-display').prettyEmbed({
	videoID: 'aBcDeFg12345',
	previewSize: 'hd',				// use either this option...
	customPreviewImage: '',			// ...or this option

	// Embed controls
	showInfo: false,
	showControls: true,
	loop: false,

	colorScheme: 'dark',
	showRelated: false,

	useFitVids: true
});

Note that html5 data-pe- attributes will take precedence over the options called programmatically. E.g. data-pe-videoid="aBcDeFg1234" takes precedence over options.videoID: '1234GfEdCbA'.

Also Note that if a particular preview image size is loading a generic gray "three dots" image, YouTube might not have generated a thumbnail in this size. Try a different size.

Options

Name Description
videoID The video ID of the YouTube video. This option will be ignored if the data-videoid attribute is present. (E.g.: aBcDeFg12345)
previewSize Preview image size pulled from YouTube. This option will be ignored if the customPreviewImage attribute is present. Available sizes from smallest to largest: thumb-default, thumb-1, thumb-2, thumb-3, default, medium, high, hd (default)
customPreviewImage Custom defined preview image URL. This option overrides options.previewSize.
showInfo Display video information (top bar).
showControls Display YouTube player controls.
loop Play video as a loop.
closedCaptions Displays closed captions (if available).
localization Changes the localization. Accepts an ISO 639-1 two-letter language code.
colorScheme Display YouTube player user interface.
showRelated Display YouTube related videos on video end.
allowFullScreen Defaults to true, can be set to false to disable the viewer from viewing in fullscreen mode.
useFitVids Call FitVids.js on .pretty-embed instances once the video(s) is/are loaded.

Changelog

v1.2.1

  • Fixed mobile player bug
  • New option: allowFullScreen which can be used to turn off fullscreen viewing mode

v1.2.0

  • Fixed those annoying "black bars" that would show up on the sides of the video once playing
  • Fixed an issue which would cause HTML5 data-pe- attributes to break
  • Removed the background-color from .pretty-embed, because be more flexible, ya know?
  • New option: closedCaptions to turn on closed captions (if available)
  • New option: localization which accepts an ISO 639-1 two-letter language code

v1.1.0

  • Better multiple instance handling
  • Fixed duplicate appended styles on multiple instances
  • Better handling of mobile - this means that placeholders are not custom on mobile since YouTube does not allow for autoplay=1 on mobile devices (boooo)
  • Added option to choose preview image size pulled from YouTube
  • Removed use of deprecated .selector property, which allowed for further minification and a cleaner application of the embedded CSS
  • Fixed ugly default border on YouTube embeds
  • Improved documentation

v1.0.0

  • Initial Release

Thanks

Thanks to the contributors and suggestions from around the web.

Thanks to alexanderdickson for waitForImages, which this plugin leverages for dynamic image previews.

Author

Mike Zarandona | @mikezarandona

PrettyEmbed.js

Comments
  • Bottom Bar does not disappear on playback

    Bottom Bar does not disappear on playback

    Screenshot

    As you can see in the screenshot attached, during playback, the bar at the bottom disappears unless your mouse is over it in a regular embed. Thought it was worth noting.

    invalid 
    opened by berfarah 6
  • Is this actually published on Bower?

    Is this actually published on Bower?

    ❯ bs pretty
    Search results:
    
        prettycheckable git://github.com/arthurgouveia/prettyCheckable.git
        jquery-prettyPhoto git://github.com/scaron/prettyphoto.git
        ng-prettyjson git://github.com/darul75/ng-prettyjson.git
        better-prettydate git://github.com/chemerisuk/better-prettydate
        prettyprint git://github.com/padolsey/prettyPrint.js
        jquery-prettydate git://github.com/jzaefferer/jquery-prettydate
        angular-pretty-checkable git://github.com/itslenny/angular-pretty-checkable.git
        pretty-bytes git://github.com/sindresorhus/pretty-bytes.git
        pretty-ms git://github.com/sindresorhus/pretty-ms.git
        prettyPrint git://github.com/padolsey/prettyPrint.js.git
        pretty-exponential git://github.com/bmcustodio/pretty-exponential.git
        jquery-prettyselect git://github.com/kajyr/jquery-prettyselect.git
        prettydiff git://github.com/austincheney/Pretty-Diff.git
        grunt-html-prettyprinter git://github.com/twolfson/grunt-html-prettyprinter.git
        pretty-scss git://github.com/rthor/Pretty-SCSS.git
        pretty-slider git://github.com/usmakestwo/pretty-slider-bower.git
    
    my_blog git/master
    ❯ bs prettyembed
    No results.
    
    my_blog git/master
    ❯ bs pretty-embed
    No results.
    
    opened by dstroot 6
  • Vertical bar, no autoplay and no loop

    Vertical bar, no autoplay and no loop

    Hi!

    Great plug-in, by the way. It's exactly what I need, except a few things.

    When I play the video, it shows vertical bars on both sides of the video, and neither autoplay nor loop=1 does not seem to work. When the page loads, the video doesn't play automatically and it doesn't loop either.

      $(function(){
        $('#bgvid').prettyEmbed({
          videoID: 'some_youtube_id',
          previewSize: 'hd',
    
          // Embed controls
          showInfo: false,
          showControls: false,
          loop: true,
    
          colorScheme: 'dark',
          showRelated: false,
    
          useFitVids: true
        });
      });
    

    Any help would be much appreciated.

    Thank you!

    bug enhancement 
    opened by yangtheman 5
  • PrettyEmbed on mobile devices. Bug?

    PrettyEmbed on mobile devices. Bug?

    I'm getting the default YouTube mobile player on mobile devices (useragent set to iPhone 3). No thumbnail - immediately showing the player. Is this the correct behavior? On desktop it works perfectly.

    wontfix 
    opened by jenbuzz 3
  • Adds allowMobilePreview

    Adds allowMobilePreview

    Adds allowMobilePreview so that a user can force the previewImage to display on mobile. Though autoplay does not work on most iPhone/Android devices, it is still useful to be able to cover the video with the image of choice on mobile.

    With this in place it may be considerable to add a customPreviewImageMobile array option for providing mobile images for various screen sizes for quicker image loading.

    opened by tylerssn 2
  • Cover image does not display in mobile (non-issue - autoplay issue acknowledged by YouTube)

    Cover image does not display in mobile (non-issue - autoplay issue acknowledged by YouTube)

    When emulating mobile in Chrome or loading prettyembed on iPhone or Android, the cover image is hidden.

    Edit: Autoplay doesn't work on all mobile devices, therefor the if(mobile) that is in place with pretty embed may be needed.

    opened by tylerssn 2
  • Can't start video on Android v. 4.1.2 (and iPhone)

    Can't start video on Android v. 4.1.2 (and iPhone)

    The video won't start on my Android Phone when clicking the play icon.

    Phone: Samsung Galaxy Android version: 4.1.2

    Browser is the default browser on Android.

    opened by carnevalle 2
  • .selector property on jQuery objects is deprecated

    .selector property on jQuery objects is deprecated

    PrettyEmbed.js uses elem = $(this) and later elem.selector to print out the css rules. As the selector property is deprecated, the css rules are generated without a selector.

    Firefox for example automatically seems to seems to use a * selector in that case. The result is play buttons appearing on every element on the page.

    I guess it would be a solution to just have the selector as an option.

    bug 
    opened by k-risc 2
  • Video ID improvement?

    Video ID improvement?

    It would be nice (better?) if the script pulled the YouTube ID from an element, rather than it having to be defined in the script itself. For example, a link; <a href="https://www.youtube.com/watch?v=ZDdq9UhTD_k">YouTube</a> would be replaced with the container / image / iframe.

    Unless I'm reading it wrong...

    enhancement 
    opened by LucPestille 2
  • added bower manifest

    added bower manifest

    No extra stuff here - just the bower.json file. If you merge this, I'll register your script to bower on your behalf under "pretty-embed". And the people, the automate-every-damn-thing people, they will love you forever.

    Note: I see that you used to have a bower manifest, and subsequently deleted it. I'm guessing that's because your script wasn't showing up on bower. If that's the case, it was because that file flagged your repo as private, which effectively disallows publishing.

    opened by erquhart 1
  • modified jquery.prettyembed.js to allow multiple instances

    modified jquery.prettyembed.js to allow multiple instances

    Added:

    $(this).attr('id', thisVideoID);
    

    Just after:

    if ( $(this).attr('data-pe-videoid') !== undefined ) { thisVideoID = $(this).attr('data-pe-videoid'); }
            else if ( $(this).attr('href') !== undefined ) { thisVideoID = youtube_parser( $(this).attr('href') ); }
            else { thisVideoID = options.videoID; }
    

    Changed:

    $(this)
    

    To:

    $(e.target)
    

    In:

     $('body').on('click', '.pretty-embed', function(e) {
            e.preventDefault();
    
            clickEventRunner( $(this) );
        });
    

    Because it seemed like this was working in the wrong context.


    Changed:

    else if ( options.videoID !== undefined ) { thisVideoID = options.videoID; }
    

    To:

    else if ( obj.attr('id') !== undefined ) { thisVideoID = obj.attr('id'); }
    

    In:

    if ( obj.attr('data-pe-videoid') !== undefined ) { thisVideoID = obj.attr('data-pe-videoid'); }
            else if ( options.videoID !== undefined ) { thisVideoID = options.videoID; }
            else {
                thisVideoID = undefined;
                console.error('PrettyEmbed.js Error:  Misformed or missing video ID.');
            }
    

    To set video id from 'id' attribute that was added earlier.

    I did not check for other use cases (such as the "HTML5 Driven Application" example).

    opened by sethbrasile 1
  • Use YouTube Iframe API for Video Insertion

    Use YouTube Iframe API for Video Insertion

    Instead of just inserting the iframe with autoplay set to true it would be better if you used the actual iframe API to insert videos. https://developers.google.com/youtube/iframe_api_reference

    This would allows manipulation of a video once its been loaded like adding a stop function that could be programmatically called just off the top of my head.

    enhancement 
    opened by sethrubenstein 0
  • Don't work with video playlist?

    Don't work with video playlist?

    it work with embed playlist too?? like iframe width="560" height="315" src="//www.youtube.com/embed/videoseries?list=PLA1BD1E862C80F959" frameborder="0" allowfullscreen></iframe

    opened by Danieler 0
Releases(v1.2.1)
A lightweight, easy-to-use jQuery plugin for fluid width video embeds.

Introducing FitVids.js A lightweight, easy-to-use jQuery plugin for fluid width video embeds. FitVids automates the Intrinsic Ratio Method by Thierry

Dave Rupert 4.8k Dec 24, 2022
Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify

Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify, apple music support . You can save your songs and play it. It also has DJ mode system.

Diwas Atreya 65 Dec 25, 2022
A simple Multi Guild Modmail Bot coded in v13 using the enmap Database Working on any host, like repl.it or vps! Its fast and working bug free + Security options!

Multiguild-Modmail A simple Multi Guild Modmail Bot coded in v13 using the enmap Database Working on any host, like repl.it or vps! Its fast and worki

Tomato6966 54 Oct 20, 2022
It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with buttons. It can play youtube songs, playlists. This bot code was made by Supreme#2401. It uses djs V12

Lofi-Radio-Music-Bot It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with butt

Diwas Atreya 89 Jan 2, 2023
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
Cloudflare Workers Discord embed & keep URL example scripts.

Using Cloudflare Workers for Discord embed support Requirements: Your own image host, on a domain that you control via Cloudflare. Limitations: 100,00

null 28 Dec 27, 2022
Djs-paginate - Simpler discord.js v13 embed pagination tool

djs-paginate Simpler discord.js v13 embed pagination tool inspired by discordjs-button-pagination. Installation npm install @eugabrielsilva/djs-pagina

Gabriel Silva 1 Jan 4, 2022
🟢 OneForAll Support Bot - Is a support bot for the discord server of OFA!

?? OneForAll Support Bot - Is a support bot for the discord server of OFA! Setup You can setup OneForAll Support Bot by simply opening your terminal/c

baby 3 Oct 15, 2022
Discord.js V14 Slash-Command and Context-Menu Handler. Most efficient and advanced Handler out there!

Base discord.js v14 Command Handler Written by Tomato6966 Made for Deezcord Features ✔ Slash Commands ✔ Sub-Slash Commands ✔ Group-Sub-Slash Commands

Tomato6966 9 Dec 21, 2022
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
A super light, fast and simple tho advanced Music Bot

A super light, fast and simple tho advanced Music Bot, without any Music Manager Packages like Lavalink, discord-player or distube. Technically providing up to all filters of lavalink, but limited to 19 predefined ones, with speed and bassboost control, as well as everything in slash Commands and message Commands!

Tomato6966 43 Dec 17, 2022
an Advanced Verification Bot for Discord, has dashboard, online captcha etc.

Verification Bot an Advanced Verification Bot for Discord, has dashboard, online captcha etc. Info & Credits This bot was made by legendjs#0001 If you

legend-js 33 Aug 30, 2022
An advanced discord bot made on Javascript with ❤ by FlyAbove

Discord JavaScript Bot An advanced discord bot made on Javascript with ❤ by FlyAbove Setup guide: Clone the repository and change config-example.json

FlyAbove 5 Apr 13, 2022
SlashCommands-Bot - An advanced discord bot, with Slash Commands !

SlashCommands Bot Github post is a discord bot handler with slashcommands in v13 How to install ? You need to have Node.JS 16+ git clone https://githu

null 9 Nov 16, 2022
Guide for Advanced Discord.js x MongoDB systems

disco.js Discord.js Guide on how to build advanced system using Mongoose and Node.js Requirements Basic Knowledge of JavaScript/NodeJS Basic+ Knowledg

Koni 39 Nov 27, 2022
Sodium is an advanced v13.6.0 discord client.

Sodium Client ➥ English Sodium is an advanced open-source client template for 13.0.6 version of Discord. It's a strict typed client like TypeScript bu

illumiii 2 Nov 14, 2022
Yet another advanced djs slash command handler made by dano with ❤️

Advanced djs slash command handler Yet another advanced djs slash command handler made by dano with ❤️ Ultimate, Efficient, Slash command handler for

null 5 Nov 7, 2022
A high-performance, interactive and customizable video player control, built upon Reanimated v2 & GestureHandler v2

`JSThread` to `JSThread`, `UIThread` to `UIThread`. React Native Reanimated Expo Player 100% written in Typescript video player component, interaction

Alan Toa 58 Jan 4, 2023