mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Created "fields" module
This should give us a little more structure as IK grows.
This commit is contained in:
parent
0b02a7158e
commit
2838fa47cd
4 changed files with 15 additions and 13 deletions
|
|
@ -33,7 +33,7 @@ Much like ``django.db.models.ImageField``, Specs are defined as properties
|
|||
of a model class::
|
||||
|
||||
from django.db import models
|
||||
from imagekit.models import ImageSpecField
|
||||
from imagekit.models.fields import ImageSpecField
|
||||
|
||||
class Photo(models.Model):
|
||||
original_image = models.ImageField(upload_to='photos')
|
||||
|
|
@ -48,7 +48,7 @@ an ImageFile-like object (just like with a normal
|
|||
photo.original_image.url # > '/media/photos/birthday.tiff'
|
||||
photo.formatted_image.url # > '/media/cache/photos/birthday_formatted_image.jpeg'
|
||||
|
||||
Check out ``imagekit.models.ImageSpecField`` for more information.
|
||||
Check out ``imagekit.models.fields.ImageSpecField`` for more information.
|
||||
|
||||
|
||||
Processors
|
||||
|
|
@ -59,7 +59,7 @@ something to it, and return the result. By providing a list of processors to
|
|||
your spec, you can expose different versions of the original image::
|
||||
|
||||
from django.db import models
|
||||
from imagekit.models import ImageSpecField
|
||||
from imagekit.models.fields import ImageSpecField
|
||||
from imagekit.processors import resize, Adjust
|
||||
|
||||
class Photo(models.Model):
|
||||
|
|
|
|||
9
imagekit/models/__init__.py
Normal file
9
imagekit/models/__init__.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from .fields import ImageSpecField, ProcessedImageField
|
||||
|
||||
|
||||
class ImageSpec(ImageSpecField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn('ImageSpec has been moved to'
|
||||
' imagekit.models.fields.ImageSpecField. Please use that'
|
||||
' instead.', DeprecationWarning)
|
||||
super(ImageSpec, self).__init__(*args, **kwargs)
|
||||
11
imagekit/models.py → imagekit/models/fields.py
Executable file → Normal file
11
imagekit/models.py → imagekit/models/fields.py
Executable file → Normal file
|
|
@ -102,13 +102,6 @@ class ImageSpecField(_ImageSpecFieldMixin):
|
|||
dispatch_uid='%s.delete' % uid)
|
||||
|
||||
|
||||
class ImageSpec(ImageSpecField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
warnings.warn('ImageSpec has been renamed to ImageSpecField. Please'
|
||||
' use that instead.', DeprecationWarning)
|
||||
super(ImageSpec, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def _get_suggested_extension(name, format):
|
||||
original_extension = os.path.splitext(name)[1]
|
||||
try:
|
||||
|
|
@ -374,7 +367,7 @@ class ProcessedImageField(models.ImageField, _ImageSpecFieldMixin):
|
|||
The ProcessedImageField constructor accepts all of the arguments that
|
||||
the :class:`django.db.models.ImageField` constructor accepts, as well
|
||||
as the ``processors``, ``format``, and ``options`` arguments of
|
||||
:class:`imagekit.models.ImageSpecField`.
|
||||
:class:`imagekit.models.fields.ImageSpecField`.
|
||||
|
||||
"""
|
||||
if 'quality' in kwargs:
|
||||
|
|
@ -398,4 +391,4 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
add_introspection_rules([], [r'^imagekit\.models\.ProcessedImageField$'])
|
||||
add_introspection_rules([], [r'^imagekit\.models\.fields\.ProcessedImageField$'])
|
||||
|
|
@ -9,7 +9,7 @@ from django.test import TestCase
|
|||
|
||||
from imagekit import utils
|
||||
from imagekit.lib import Image
|
||||
from imagekit.models import ImageSpecField
|
||||
from imagekit.models.fields import ImageSpecField
|
||||
from imagekit.processors import Adjust
|
||||
from imagekit.processors.resize import Fill
|
||||
from imagekit.processors.crop import SmartCrop
|
||||
|
|
|
|||
Loading…
Reference in a new issue