Skip to content

Instantly share code, notes, and snippets.

@james2doyle
james2doyle / placeholder-svg.php
Last active May 23, 2019 07:31
Create simple placeholder images using SVG
<?php
// Usage: <img src="placeholder-svg.php?wh=400x400&fill=bada55&color=000000&font=Georgia&size=20" />
$wh = explode('x', $_GET['wh']);
$wh[0] = (int)$wh[0];
$wh[1] = (int)$wh[1];
$fill = isset($_GET['fill']) ? $_GET['fill']: '666666';
$color = isset($_GET['color']) ? $_GET['color']: 'FFFFFF';
$size = isset($_GET['size']) ? (int)$_GET['size']: 60;
$fontfamily = isset($_GET['font']) ? $_GET['font']: 'Arial';
header('Content-Type: image/svg+xml');