Embed icon indicating copy to clipboard operation
Embed copied to clipboard

Iframe code width and height

Open wyllyjon opened this issue 3 years ago • 2 comments

Hello,

I allow users to import some videos in their profile, and it can be done from various sources (Vimeo, dailymotion, Youtube, etc.) But the sizes of the iframe got from $info->code->html are not the same acording to the source.

Is there a way (except javascript) to set the width and height in the code with your library ?

Thanks for the help !

wyllyjon avatar Feb 25 '22 08:02 wyllyjon

The best way to set a width & height to iframes is with CSS. Websites don't always return width and height values or they don't match with the values in the html code. Sometimes is more useful the aspect-ratio value, because it allows to set any size to the iframe keeping the same proportions.

oscarotero avatar Feb 25 '22 10:02 oscarotero

You can use the aspect-ratio css property for that https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio Or if you need compatibility with old browsers the padding trick: https://nikitahl.com/css-aspect-ratio

oscarotero avatar Feb 25 '22 10:02 oscarotero