Giter VIP home page Giter VIP logo

placeholder's Introduction

img-src.co Placeholder Image Generator

Build Status

About

PHP placeholder image generator used on http://img-src.co.

Requirements

  • PHP 5.1.0 or higher

How to use

Quick start

  1. Copy the /i/ folder and all of its contents to your web root directory.
  2. You're now ready to make placeholder images using the following format:
    <img src="/i/?w={width}&h={height}&bgColor={background color hex}&textColor={text color hex}" />

Examples:

<img src="/i/?w=50&h=50" />
<img src="/i/?w=50&h=80" />
<img src="/i/?w=50&h=80&bgColor=eee" />
<img src="/i/?w=50&h=80&bgColor=eee&textColor=999" />

Advanced setup ("pretty URLs")

  1. Copy the /i/ folder and all of its contents to your web root directory.
  2. Set up the rewrite rules for your web server (see below).
  3. You're now ready to make placeholder images using the following format (background & text colors are optional):
    <img src="/{width}/{height}/{background color hex}/{text color hex}" />

Examples:

<img src="/50" />
<img src="/50x80" />
<img src="/50x80/eee" />
<img src="/50x80/eee/999" />

Apache rewrites: This can either go in an .htaccess file or your site config file. A sample .htaccess file is included in the repository.

RewriteEngine On
RewriteBase /
RewriteRule ^(\d+)/?$ /i/index.php?w=$1&h=$1
RewriteRule ^(\d+)x(\d+)/?$ /i/index.php?w=$1&h=$2
RewriteRule ^(\d+)/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/?$ /i/index.php?w=$1&h=$1&bgColor=$2
RewriteRule ^(\d+)x(\d+)/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/?$ /i/index.php?w=$1&h=$2&bgColor=$3
RewriteRule ^(\d+)/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/?$ /i/index.php?w=$1&h=$1&bgColor=$2&textColor=$3
RewriteRule ^(\d+)x(\d+)/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/([a-fA-F0-9]{3}|[a-fA-F0-9]{6})/?$ /i/index.php?w=$1&h=$2&bgColor=$3&textColor=$4

Nginx rewrites: This needs to go in your site config file. A sample config file is included in the repository that can be included by your site config.

location ~* "^/(\d+)x(\d+)/([a-f0-9]{3}|[a-f0-9]{6})/([a-f0-9]{3}|[a-f0-9]{6})/?$" {  
  try_files $uri $uri/ /i/index.php?w=$1&h=$2&bgColor=$3&textColor=$4;  
}  
location ~* "^/(\d+)/([a-f0-9]{3}|[a-f0-9]{6})/([a-f0-9]{3}|[a-f0-9]{6})/?$" {  
  try_files $uri $uri/ /i/index.php?w=$1&h=$1&bgColor=$2&textColor=$3;  
}  
location ~* "^/(\d+)x(\d+)/([a-f0-9]{3}|[a-f0-9]{6})/?$" {  
  try_files $uri $uri/ /i/index.php?w=$1&h=$2&bgColor=$3;  
}  
location ~* "^/(\d+)/([a-f0-9]{3}|[a-f0-9]{6})/?$" {  
  try_files $uri $uri/ /i/index.php?w=$1&h=$1&bgColor=$2;  
}  
location ~ "^/(\d+)x(\d+)/?$" {
  try_files $uri $uri/ /i/index.php?w=$1&h=$2;  
}  
location ~ "^/(\d+)/?$" {
  try_files $uri $uri/ /i/index.php?w=$1&h=$1;  
}

Support

To report a bug, please use our GitHub issue tracker. Better yet, if you find a bug, feel free to fork our code and submit a pull request with your fix.

License

The img-src.co placeholder image generator is distributed under the terms of the MIT license. copyright © 2012-2013

placeholder's People

Contributors

briankiewel avatar

Watchers

Rien avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.