Solved

Standalone Image on Click YouTube Video

Posted on 2014-02-25
3
477 Views
Last Modified: 2014-02-25
I have a YouTube video on my website that before played shows the preview image that's very pixelated.  I want to put a high resolution image on my website that on click will then play the youtube video, is there a way to do this?
0
Comment
Question by:N R
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
quizwedge earned 500 total points
ID: 39887284
You can do something like the following

<img id="high_res_image" src="high_res_image.jpg">
<div id="youtube_video" style="display:none;">
<!-- Put YouTube Video code here -->
</div>

Open in new window


This will show the image and hide the YouTube video. Then, in jQuery you'll need the following:

$( "#high_res_image" ).click(function() {
  $('#high_res_image").hide();
  $(#youtube_video).show();
  $('#youtube_video').('iframe')[0].src += "&autoplay=1";
});

Open in new window


What this will do is hide the high resolution image, show the YouTube div and then add autoplay=1 to the YouTube video iframe to (hopefully) start autoplay. Haven't tested it, but I think it should work in theory.
0
 
LVL 11

Author Comment

by:N R
ID: 39887376
Hmm...not working for me here is a sample of my setup here on jsfiddle:
http://jsfiddle.net/4qFrr/

Maybe I've mistyped something in my code?
0
 
LVL 11

Author Closing Comment

by:N R
ID: 39887818
Had to tweak the jquery some:
$( "#high_res_image" ).click(function() {
  $( "#youtube_video" ).show( "slow" );
  $( "#high_res_image" ).hide( "slow" );
});

Open in new window

0

Featured Post

Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question