July 23, 201016 yr 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>
July 23, 201016 yr 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
July 23, 201016 yr 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.
July 23, 201016 yr 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?
July 24, 201016 yr 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! :-)
July 24, 201016 yr Have you specified width and height for div that video is in? This should help keep the dimensions of page in tact.
July 26, 201016 yr 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
July 31, 201016 yr 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