Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RoelWKramer/811224 to your computer and use it in GitHub Desktop.
Save RoelWKramer/811224 to your computer and use it in GitHub Desktop.
from django import forms
image = object # pseudo voor de goede syntax hilighting
class Images(object):
''' Dit wordt het magische images object, dat de form afspeurt naar de form
fields die van het type ImageField (of andere naam) zijn. '''
pass
class MyForm(forms.Form):
image_frontpage = forms.ImageField()
image_newsitem = forms.ImageField()
photo_1 = forms.ImageField()
photo_2 = forms.ImageField()
photo_3 = forms.ImageField()
def __unicode__(self):
return self.image.nam
class MyFormImages(Images):
image_frontpage = image.FixedAspectRatio(x=4, y=3)
image_newsitem = image.MultipleFixedAspectRatio((
('x', 1, 'y', 1, 'tab_title', 'icon'),
('x', 4, 'y', 3, 'tab_title', 'inline'),
('x', 16, 'y', 9, 'tab_title', 'zoomed'),
))
photo_1 = image.MultipleVariableAspectRatio((
('tab_title', 'small'),
('tab_title', 'large'),
('tab_title', 'detail'),
))
photo_2 = image.MultipleMixedAspectRatio((
('tab_title', 'small'),
('tab_title', 'large'),
('x', 1, 'y', 1, 'tab_title', 'detail'),
))
photo_3 = image.VariableAspectRatio()
class Meta:
form = MyForm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment