Youtube embed size, revisited


(Bart) #1

I’m following up on ‘Youtube embed size’. In this topic, the discussion was about the small default size of YouTube embeds. The final solution was allowing width and height parameters in YouTube links. I’m not sure this is a great solution as most forum users will not know about these.

What’s currently the best approach to make YouTube embeds the same size as images?

Somewhat on the same topic, Vimeo embeds are larger than YouTube embeds but still not the same size as images.


(Brendan Schlagel) #2

This is what we have currently to make YouTube embeds span the full post width:

.lazyYT-container {
    height: 0 !important;
    width: 100% !important;
    padding-bottom: 56.25% !important;
}

IMO this is a big improvement and something like this should just be the default styling!

Not sure how to do the same for Vimeo (but YouTube accounts for probably like 99% of videos shared on our forum so not something we’ve worried about too much…)


Making embedded (linked) video stretch to the edges of the topic
(Bart) #3

Brilliant, thanks!

True enough :slight_smile:


#4

this looks perfect, thank you so much!


(Lee Davy) #5

Hi there.

I am new here, hence the late reply.

My YouTube videos look small and have a black border, and I don’t know how to change the width and remove the border. I have read your response, but don’t understand what to do. I was wondering if you could explain it to someone who has no clue about this type of thing.

Here is a screenshot


(Brendan Schlagel) #6

What I posted is custom CSS, which you can add by going to Admin > Customize, and then adding that to a theme or theme component by clicking “Edit CSS/HTML” and pasting into the Common > CSS section.

If you don’t already have a custom theme, I think you can either add the CSS directly to your default theme, or make a new theme component, add the CSS there, and then make sure that component is added to the main theme.

This may sound confusing if you’re not yet familiar with Discourse themes / customization at all. Give this a read for more detail and it should start to make sense how it all works! —


(Lee Davy) #7

Hi Brendan,

That’s a lot of complicated reading.

Isn’t there a straight forward…go to YouTube, click on ‘x’ change ‘y’ and hey presto?


(Brendan Schlagel) #8

That guide is just background reading if you get lost, but you should basically be able to just copy-paste that code to your theme and have it work.

You may be able to pass the width/height params as part of the YouTube URL (as per this post), but this customization is currently needed to change the default way Discourse displays YouTube videos.

I do agree Discourse could handle this better by default though so this customization isn’t needed! @Johani would you consider making this the default for video embeds? Would make for more consistent design (e.g. I believe oneboxes, large images, etc. always display full-width…)


(Lee Davy) #9

I am still unsure how to adjust the height and width of an individual post. I can see that it should be 690 & 400, but my link (for an unlisted YouTube video) doesn’t contain height or width like it does in the example you sent me.


(Brendan Schlagel) #10

Hmmm just tested and it looks like that method still works? You just append &width=690&height=400 to the first part of the URL e.g. https://www.youtube.com/watch?v=4CJvasYJP6o

But yeah you’d have to do this for every single video so the method above is definitely better to have consistent video display for the whole forum e.g. if any other users besides yourself may be posting video links.