Better Way to Resize Video using jQuery

I have already written a little jQuery snippet to resize videos but I came across an article by Chris Coyier with an approach that I thought worked a lot better. Though I did add a few tweaks to it:


Now your videos will only be resized if they are larger than the parent container. In the instance above, I have set the parent container to the paragraph tag surrounding the video (in WordPress, a paragraph tag is automatically added to each paragraph). If your site uses a different container, you can easily change that one line to the tag, ID or class of your parent container.

newWidth = el.parents( '.class-name' ).width(),

Share this:

Email
Facebook
Twitter
Pinterest
Pocket

Premium Themes for WordPress

Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

Use this WordPress website builder to build powerful websites in no time for your or your clients.

WordPress Hosting

WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

Bluehost – providing quality web hosting solutions since 1996.

About the author

Picture of Luke Perrie

Luke Perrie