Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Embedding YouTube

Featured Replies

Hi Guys

 

I've embedded a link to a YouTube video on a site and I'm happy with how it looks. However sometimes the video doesn't appear at all.

 

The problem is that often it doesn't load and this wrecks the layout of the page. What I'd like to be able to do (in PHP or maybe JavaScript) is to detect when the video isn't there and put up an image instead.

 

Any ideas? All thoughts much appreciated!

 

Cheers!

 

<div id="screen">
<div class="ytvideo">
	<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/IPiddv6_i24&hl=en_GB&fs=1?rel=0&autoplay=0" width="250" height="212"><param name="movie" value="http://www.youtube.com/v/CRTAkt-Suz0"><param name="FlashVars" value="playerMode=embedded"><param name="wmode" value="transparent"></object>
</div>
<h2>Hello</h2>
<p>Eighth Wonder - I'm Not Scared</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

Not sure if this is the proper solution, but you could put a transparent background image the same size as your video in the div so when the video doesnt load it still wont wreck the layout

  • Author

Not sure if this is the proper solution, but you could put a transparent background image the same size as your video in the div so when the video doesnt load it still wont wreck the layout

 

Thanks, Pat, I like that idea.

 

It wouldn't be able to link through to YouTube itself though.

Thanks, Pat, I like that idea.

 

It wouldn't be able to link through to YouTube itself though.

 

Can't you make the image a link to the video itself?

  • Author

Can't you make the image a link to the video itself?

 

Of course - I'm being really dumb. I forgot that the background image can be clickable!

 

Thanks! :-)

Have you specified width and height for div that video is in? This should help keep the dimensions of page in tact.

  • Author

Have you specified width and height for div that video is in? This should help keep the dimensions of page in tact.

 

Good point but, yes, I have done this. The real issue is that I don't know when the YouTube video isn't going to appear.

 

Thanks

Of course - I'm being really dumb. I forgot that the background image can be clickable!

 

Thanks! :-)

Haha, no problem :).

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.