Last active
August 27, 2018 07:57
-
-
Save dfinke/c643dc1458c19a16672bd547461ad34f to your computer and use it in GitHub Desktop.
Generate the YouTube html for an image with a link to the video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-YouTubeLinkAndThumbnail { | |
param( | |
[Parameter(Mandatory)] | |
$YouTubeVideoID, | |
$Width=240, | |
$Height=180, | |
$ImageAltText='IMAGE ALT TEXT HERE', | |
[Switch]$DontCopyToClipboard | |
) | |
$html = @" | |
<a href="http://www.youtube.com/watch?feature=player_embedded&v=$($YouTubeVideoID)" target="_blank"> | |
<img src="http://img.youtube.com/vi/$($YouTubeVideoID)/0.jpg" alt="$($ImageAltText)" width="$($Width)" height="$($Height)" /> | |
</a> | |
"@ | |
if($DontCopyToClipboard) { $html; return } | |
$html | clip | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment