main image should get default model extra image correctly

This commit is contained in:
Sanj 2012-01-02 23:59:30 +05:30
parent 41ac4c2dd2
commit 378c61f743

View File

@ -87,20 +87,19 @@ class ItfModel(models.Model):
def get_main_image(self): def get_main_image(self, size="142x150"):
if hasattr(self, 'main_image'): if hasattr(self, 'main_image'):
main_image_getter = self.main_image main_image_getter = self.main_image
if type(main_image_getter).__name__ == 'instancemethod': if type(main_image_getter).__name__ == 'instancemethod':
imgfield = main_image_getter() imgfield = main_image_getter()
else: else:
imgfield = main_image_getter imgfield = main_image_getter
elif self.get_modelextra().default_image: if imgfield.name == '':
imgfield = self.get_modelextra().default_image imgfield = self.get_modelextra().default_image
else:
imgfield = None if imgfield:
if imgfield is not None:
try: try:
thumb = get_thumbnail(imgfield, "142x150", crop="center").url thumb = get_thumbnail(imgfield, size, crop="center").url
except: except:
thumb = '' thumb = ''
else: else: