WordPress: Create Your Own YouTube Embed Code

I have yet to find a good way of embedding YouTube videos in WordPress posts. If you copy the embed code YouTube provides, it’ll work unless you switch to the visual editor which mangles such code. If you look for a plugin to help you with the embedding, you’re in for an experience less pleasant than not using the visual editor.

A future version of WordPress promises to change this and give us mediatags to properly embed things. Until then, I would suggest you avoid the plugin repository entirely and use this little code snippet to write your own little shortcode tag to do the trick:

 * YouTube Shortcodes
add_shortcode('youtube', 'insertYouTube');
add_shortcode('yt', 'insertYouTube');

// Insert YouTube function
function insertYouTube($attr) {

	// defaults
	if (!$attr['width']) {
		$yt_w = 500;
	} else {
		$yt_w = $attr['width'];
	if (!$attr['height']) {
		$yt_h = 400;
	} else {
		$yt_h = $attr['height'];

	$yt .= '';

	// output YT
	if ($attr['src']) {
		$yt_id = str_replace( "=" , "" , $attr['src'] ) ;
		$yt_id = str_replace( "http://www.youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "https://www.youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "http://youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "https://youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = split('&', $yt_id);
		$yt_id = $yt_id[0];

	} else if ($attr[0]) {

		$yt_id = str_replace( "=" , "" , $attr[0] ) ;
		$yt_id = str_replace( "http://www.youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "https://www.youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "http://youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = str_replace( "https://youtube.com/watch?v" , "" , $yt_id ) ;
		$yt_id = split('&', $yt_id);
		$yt_id = $yt_id[0];


	// output
	$yt .= '
        You need the Flash Player.

	$yt .= '';
	return $yt;



[youtube src="" width="500" height="400"]

Dump the above in your themes functions.php file, or pluginify it. I’m releasing this code under a Creative Commons Attribution 3.0 Unported License.

Creating Microworlds In Photoshop


It started with some beautiful pictures by Russian artist Alexandre Duret-Lutz and moved on to a discussion: how was this done? Well, the following technique might not be exactly the same one, but at least it’s really quick and rather hilarious.



Find a good landscape. Preferrably a large image without too much going on in the sky as the sky will become a bit distorted.


In this case, I had the tree in separate layer, so I cut that out. The sky is going to be stretched quite a bit, so let’s be clean.



If you want a round globe-like end-result picture, your canvas has to be a perfect square. I expanded the canvas (Image - Canvas Size...) so the width and height were the same. I filled the new room with sky blue. It doesn’t matter so much, as the topmost part of the sky will end up so distorted that we’ll crop it away.

Flip It


The filter we’re about to use is pretty old, so you’ll have to do most of the work outside of the filter. So flip it vertically.



Now it’s filter time: run the Filters - Distort - Polar Coordinates... filter.


It’ll look like this.



Zoom all the way in, and using the Clone Stamp tool, diligently paint over the vertical seam that goes from the middle, all the way up to the top of our sphere. The Clone Stamp (keyboard shortcut S) is used by holding ALT, then clicking a spot nearby where you want to smooth over things. Once you’ve selected a “clone source” you can paint normally and it’ll clone the spot you selected.


I added back the tree I removed early on, for maximum fun.


Voilá. Surreal Mario Galaxy.

Here are a few more pictures:




Creating Smoke In Photoshop From Scratch


Using Photoshop and a specific technique, it’s rather easy to create something that looks like smoke or fog—from scratch. It’s not as good as actual smoke photographed on a black background, but it’s much easier to come by. Here’s the trick…



Draw a doodle. Preferrably keep the doodle in its own layer with a black background beneath.



Use the Liquify tool to distort the doodle. Liquify resides in the Filter > Liquify... menu. Using the various “forward warp”, “twirl” and “pucker” tools residing in the menu to the left, you distort the doodle as if you were fingerpainting.


Once you’ve applied the liquify transformation, select Edit > Fade Liquify.... In the dialog box that appears, set the opacity to 50% and apply.


Now repeat the process until you’re satisfied:

  1. Liquify
  2. Fade Liquify to 50%






smoke09 smoke10

If you enjoyed this tutorial, you might also enjoy my Creating Microworlds in Photoshop tutorial.