Example #1
0
def pre_on_store_save(sender, **kwargs):
    store = kwargs['instance']
    if store.photo:
        max_width = 500
        if store.photo.width > max_width or store.photo.height > max_width:
            processed_file = thumbnail(store.photo.file, max_width, max_width)
            store.photo.save(store.photo.name, File(processed_file))
Example #2
0
def pre_on_user_profile_save(sender, **kwargs):
    user_profile = kwargs['instance']
    if user_profile.photo:
        max_width = 500
        if user_profile.photo.width > max_width or user_profile.photo.height > max_width:
            processed_file = thumbnail(user_profile.photo.file, max_width, max_width)
            user_profile.photo.save(user_profile.photo.name, File(processed_file))