Shake it Off

Sure a cute commercial that Taylor Swift did for Gap.

Advertisements

YouTube Embederrator

Needed a simple WordPress function to provide a way to build a YouTube video embed. This is a nice little trick. All you need to do is add a custom field that has a key of Big_Video and the value of the ID of the YouTube video.

[php]
function js_youtube_embed($width,$height) {
global $wp_query;
$big_video = get_post_custom_values(‘Big_Video’);
?>
<iframe width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="http://www.youtube.com/embed/<?php echo $big_video[0]; ?>?showinfo=0&hd=1" frameborder="0" allowfullscreen></iframe>
<?php } ?>
[/php]

Example, if this is your YouTube video: http://www.youtube.com/watch?v=C1p6A7X64Qg, you would use C1p6A7X64Qg as the value.

In you template, the function would look like this:

[php]
js_youtube_embed(‘940’, ‘528’);
[/php]

The two values are the size of the video that you want embedded. So, in this case 940×528.