Skip to main content

A fully featured drop-in replacement of placehold.it for Django

Project description

A fully featured drop-in replacement of placehold.it for Django

https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/160.gif https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/custom-dimensions.gif https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/custom-text.gif
https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/custom-colors.gif https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/automatically.gif https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/formats.jpg
https://raw.githubusercontent.com/stevelacey/django-placeholdit/master/examples/scaled.gif

Features

  • Everything placehold.it does

  • Identical URL structure

  • Improved font rendition and vertical text alignment

Installation

You can pip install the app from PyPi (recommended):

$ pip install django-placeholdit

or GitHub:

$ pip install git+git://github.com/stevelacey/django-placeholdit.git#egg=DjangoPlaceholdit

Add django_placeholdit to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    # ...
    'django_placeholdit',
)

Add the routes into your urls.py, feel free to customise the prefix or namespace, no trailing slash:

urlpatterns = patterns(
    # ...
    url(r'^placeholders', include('django_placeholdit.urls', namespace='placeholdit')),
)

Configuration

The following options can be configured in your settings.py:

PLACEHOLDIT_CACHE_SECONDS # Number of seconds to cache placeholders. Defaults to 86400 * 7 (a week)

Usage

In templates:

<img src="{% url 'placeholdit:placeholder' width=160 %}">
<img src="{% url 'placeholdit:placeholder' width=240 height=160 text='Custom dimensions' %}">
<img src="{% url 'placeholdit:placeholder' width=160 text='Custom text!' %}">
<img src="{% url 'placeholdit:placeholder' width=160 background='F77A00' color='fff' text='Custom colors!' %}">
<img src="{% url 'placeholdit:placeholder' width=240 height=80 background='fbd206' color='fff' text='Automatically' %}">
<img src="{% url 'placeholdit:placeholder' width=240 height=80 background='fbd206' color='fff' text='scaled!' %}">
<img src="{% url 'placeholdit:placeholder' width=160 background='93C663' color='3F740E' text='gif/jpeg/png' format='jpg' %}">

Resulting in:

<img src="http://example.com/placeholders/160">
<img src="http://example.com/placeholders/240x160&text=Custom%20dimensions">
<img src="http://example.com/placeholders/160&text=Custom%20text%21">
<img src="http://example.com/placeholders/160/F77A00/fff&text=Custom%20colors%21">
<img src="http://example.com/placeholders/240x80/fbd206/fff&text=Automatically">
<img src="http://example.com/placeholders/240x80/fbd206/fff&text=scaled%21">
<img src="http://example.com/placeholders/160.jpg/93C663/3F740E&text=gif/jpeg/png">

Contributing

Feel free to fork django-placeholdit on GitHub! I’d love to see your pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-placeholdit-1.0.2.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file django-placeholdit-1.0.2.tar.gz.

File metadata

File hashes

Hashes for django-placeholdit-1.0.2.tar.gz
Algorithm Hash digest
SHA256 432b36aee8a36dfadc32e6198530b30459c27cdec741aec66907e6f428100dbe
MD5 9fb6be4a6dcf0972358dce64c1de5737
BLAKE2b-256 69ef5552c281e8c276244ee3103f18f2dfd20c145ffacd2771141ebac2d61668

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page