In my article about My take on a Vending Machine Simulation, I wanted to include a link to my Gist, together with a nice thumbnail. Having installed Nzymes on my blog, that wasn’t too difficult.

I thought about using an injection like this:

´{[ =<URL of the file>= | 1.thumb(1) ]}´

so that I could easily reuse it just by changing the URL.

Here are the contents of the execution enzyme.

thumb

list( $url, $size, $target ) = array_pad( $arguments, 3, null );
if (! $size) $size = 'x';
if (! $target) $target = '_blank';

$src = "http://free.pagepeeker.com/v2/thumbs.php?size=$size&url=" . urlencode($url);
$img = "<img src='$src' />";
$result = "<a href='$url' target='$target'>$img</a>";
return $result;

The idea is to rely on the PagePeeker free service and return a properly built A IMG element.