Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active August 27, 2018 07:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfinke/c643dc1458c19a16672bd547461ad34f to your computer and use it in GitHub Desktop.
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
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