Skip to content

Instantly share code, notes, and snippets.

@pietvanzoen
Created July 8, 2013 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pietvanzoen/5950646 to your computer and use it in GitHub Desktop.
Save pietvanzoen/5950646 to your computer and use it in GitHub Desktop.
Image Placeholders :: Helper functions for placeholder image services such as http://Placehold.it and http://Placekitten.com. #php
<?php
// http://placehold.it
function placeholdit($width = 100, $height = '', $text = '', $colors = '')
{
$dimentions = $width.( !empty($height) ? 'x'.$height : '');
$text = !empty($text) ? '&text='.urlencode($text) : '';
$colors = !empty($colors) ? explode(' ', $colors) : '';
$colors = !empty($colors) ? '/'.$colors[0].'/'.$colors[1] : '';
return 'http://placehold.it/'.$dimentions.$colors.$text;
}
// http://placekitten.com
function placekitten($width = 100, $height = '', $grey = false)
{
$dimentions = $width.( !empty($height) ? '/'.$height : '');
$g = $grey === true ? 'g/' : '';
return 'http://placekitten.com/'.$g.$dimentions;
}
// http://placecage.com
function placecage($width = 100, $height = '', $style = '')
{
$dimentions = $width.( !empty($height) ? '/'.$height : '');
$s = (empty($style) ? '' : $style.'/');
return 'http://placecage.com/'.$s.$dimentions;
}
// http://fillmurray.com
function fillmurray($width = 100, $height = '', $style = '')
{
$dimentions = $width.( !empty($height) ? '/'.$height : '');
$s = (empty($style) ? '' : $style.'/');
return 'http://fillmurray.com/'.$s.$dimentions;
}
// http://fillmurray.com
function nicenicejpg($width = 100, $height = '', $style = '')
{
$dimentions = $width.( !empty($height) ? '/'.$height : '');
$s = (empty($style) ? '' : $style.'/');
return 'http://nicenicejpg.com//'.$s.$dimentions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment