GitXplorerGitXplorer
g

django-nailbiter

public
2 stars
6 forks
0 issues

Commits

List of commits on branch master.
Unverified
60edd93710bfd593eb8313ce7b0b8b98109b201d

whoops; removed a debugging dir

committed 15 years ago
Unverified
aa1c7590d2845e8b258ed16ca47fc2afefc17d9d

added some validation so we don't break things if there's no file stored yet

committed 15 years ago
Unverified
2679d87b4865f85819370b26d09472c415ee38c9

modified to work as a package for setuptools/pip

committed 15 years ago
Unverified
1698c10c6eb8f3321f7825ac894fb2f4dbf6a1bf

fixed broken tab in README

mmattdennewitz committed 15 years ago
Unverified
7073e0430fa4cc6ff1d227ca994bcf6097ce0f3f

updated README

mmattdennewitz committed 15 years ago
Unverified
23865d2cf6cc21e46f7a6f6a4319dff3d63eaa82

updated README

mmattdennewitz committed 15 years ago

README

The README file for this repository.

============================================================= django-nailbiter - a storage-agnostic thumbnail generator

nailbiter is a simple thumbnail generation field for Django, modeled after sorl-thumbnail.

Usage

First, define a model using a nailbiter thumbnail field:

In models.py::

from django.contrib.auth.models import User
from django.db import models
from nailbiter.fields import ImageWithThumbsField

class Gallery(models.Model):
    name = models.CharField(max_length=150)
	

class Photo(models.Model):
    uploader = models.ForeignKey(User, related_name="photos")
    gallery = models.ForeignKey(Gallery, related_name="photos")
    title = models.CharField(max_length=150)
    image_file = ImageWithThumbsField(
        upload_to = photo_upload_path,
        generate_on_save = True,
        thumbnail = {'size': (150, 150), 'options': ['detail']},
        extra_thumbnails = {
            'headline': {'size': (300, 300), 'options': ['upscale', 'detail']},
            'avatar': {'size': (64, 64), 'options': ['crop', 'upscale', 'detail']},
            'gallery_icon': {'size': (150, 150), 'options': ['crop', 'upscale', 'detail']}})
    created_date = models.DateTimeField(default=datetime.utcnow)

To display the thumbnail in a template: ::

<img src="https://raw.githubusercontent.com/girasquid/django-nailbiter/master/{{ object.image_file.thumbnail.url }}" />

To display a thumbnail defined in extra_thumbnails, just refer to it by the name you defined: ::

<img src="https://raw.githubusercontent.com/girasquid/django-nailbiter/master/{{ object.image_file.headline.url }}" />