Skip to content

Instantly share code, notes, and snippets.

@jondavidjohn
Created July 13, 2012 20:42
Show Gist options
  • Save jondavidjohn/3107336 to your computer and use it in GitHub Desktop.
Save jondavidjohn/3107336 to your computer and use it in GitHub Desktop.
Rewrite Wordpress uploads to lorempixel (Nginx)
# if you're requesting anything within '/wp-content/uploads' or '/files'
location ~ (/wp-content/uploads|files) {
# and it doesn't exist
if (!-e $document_root$uri) {
# try and match the dimensions from the filename
rewrite (\d+)(?:x)(\d+)(?:\.(?:[^\.]+)$) http://lorempixel.com/$1/$2 break;
# otherwise just use a default size
rewrite .* http://lorempixel.com/800/600 break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment