Anwen
January 15, 2024, 5:43pm
1
What I’m trying to do
I regularly insert youtube videos into notes via iframes. I used to have no problems. Recently, I can’t get them at the size I want.
I tried again with a test vault.
Without plugins, snippets or themes:
with this :
<iframe src="https://www.youtube.com/embed/DbsAQSIKQXk" title="YouTube video player" allowfullscreen></iframe>
with this:
<iframe height="100%" width="100%" src="https://www.youtube.com/embed/DbsAQSIKQXk" title="YouTube video player" allowfullscreen></iframe>
or this:
<iframe width="100%" src="https://www.youtube.com/embed/DbsAQSIKQXk" title="YouTube video player" allowfullscreen></iframe>`
I tried to modify with css but impossible m correct to have a video of the width of the note with the right ratio. Would anyone have an idea ?
Does setting a width of 100%
and a fixed height work for you?
<iframe width="100%" height="310" src="https://www.youtube.com/embed/DbsAQSIKQXk" title="YouTube video player" allowfullscreen></iframe>
Anwen
January 16, 2024, 8:38am
3
Thank you for your response.
I actually manage to get a good ratio like this:
<iframe width="100%" height="512" src="https://www.youtube.com/embed/DbsAQSIKQXk" title="YouTube video player" allowfullscreen></iframe>
But I used to be able to do it with just 100% and 100%. Isn’t there a way to get a good ratio for all videos without having to harden the size?
ariehen
January 16, 2024, 10:02am
4
I’m not sure about that. I don’t use iframes in my vault. Can you pinpoint what Obsidian version the behavior changed for you?
Anwen
January 16, 2024, 10:29am
5
I’m in the v1.5.3, but I don’t sure that it appeared with this version.
ariehen
January 16, 2024, 10:39am
6
You could try something like this for all YouTube iframes. The border-radius: 30px;
section is optional. It seems to work in live preview and reading modes.
iframe[src*="youtu"] {
width: 100%;
height: 512px;
border-radius: 30px;
}
…at least you won’t have to put the width and height in each iframe, but I understand this still isn’t ideal.
Anwen
January 16, 2024, 10:54am
7
It works well enough to keep this, thank you.
system
Closed
January 23, 2024, 10:54am
8
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.