close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Here's how to make embeds into PowerCMS from YouTube and Vimeo Responsive

Thread began 1/31/2016 11:00 pm by cldsk | Last modified 2/02/2016 5:16 pm by cldsk | 439 views | 0 replies

cldsk

Here's how to make embeds into PowerCMS from YouTube and Vimeo Responsive

Hello, I thought I would just post this to share. I have tried a few different things that didn't seem to work, and stumbled upon this that does work with PowerCMS!

This is a technique that works for making the iframe embed codes from YouTube and Vimeo responsive if clients paste them into the "Source" in PowerCMS:

It comes from:
https://toddmotto.com/fluid-and-responsive-youtube-and-vimeo-videos-with-fluidvids-js/

The only limitation I see is that it isn't specific to the smaller screens (it makes videos on a computer monitor 100% width vs. the width specified in the original embed code). If someone knows how to adapt it, that would be great to know!

It is as easy as adding in the following code before the closing body tag in your pages:

<script>(function ( window, document, undefined ) {

/*
* Grab all iframes on the page or return
*/
var iframes = document.getElementsByTagName( 'iframe' );

/*
* Loop through the iframes array
*/
for ( var i = 0; i < iframes.length; i++ ) {

var iframe = iframes[i],

/*
* RegExp, extend this if you need more players
*/
players = /www.youtube.com|player.vimeo.com/;

/*
* If the RegExp pattern exists within the current iframe
*/
if ( iframe.src.search( players ) > 0 ) {

/*
* Calculate the video ratio based on the iframe's w/h dimensions
*/
var videoRatio = ( iframe.height / iframe.width ) * 100;

/*
* Replace the iframe's dimensions and position
* the iframe absolute, this is the trick to emulate
* the video ratio
*/
iframe.style.position = 'absolute';
iframe.style.top = '0';
iframe.style.left = '0';
iframe.width = '100%';
iframe.height = '100%';

/*
* Wrap the iframe in a new <div> which uses a
* dynamically fetched padding-top property based
* on the video's w/h dimensions
*/
var wrap = document.createElement( 'div' );
wrap.className = 'fluid-vids';
wrap.style.width = '100%';
wrap.style.position = 'relative';
wrap.style.paddingTop = videoRatio + '%';

/*
* Add the iframe inside our newly created <div>
*/
var iframeParent = iframe.parentNode;
iframeParent.insertBefore( wrap, iframe );
wrap.appendChild( iframe );

}

}

})( window, document ); </script>




In my case, I created a php include and just called up the include at the bottom of each page. I hope this is helpful to some in the WebAssist Community

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...