Question

I don't know what I'm doing wrong, but sorl-thumb just uploads the image but doesn't make thumbs...

model.py

 from sorl.thumbnail.fields import ImageWithThumbnailsField ,ThumbnailField

 imagen = ImageWithThumbnailsField(upload_to='images',
                                      thumbnail={'size': (75, 75)},
                                      extra_thumbnails={'icon': {'size': (25, 25),'options': ['crop', 'upscale']},
                                                        'large': {'size': (200, 400)},
                                                        },
                                    )

setting

'sorl.thumbnail',

What more do I need? I've followed the documentation.

Was it helpful?

Solution

Did you read the documentation on when thumbnails are created?

You haven't actually explained exactly what your problem is. Edit your original question to show something you are trying to do (along with both the actual and expected results).

EDIT: As the docs say, your images are not created until they are used. If you want thumbs to be generated when the image is initially uploaded, use the generate_on_save attribute like this:

ImageWithThumbnailsField(..., generate_on_save=True)

OTHER TIPS

I dont know sorl, but I would say, you need to add ImageWithThumbnailsField as a field inside a model

class MyImage(models.Model):
    image = ImageWithThumbnailsField(upload_to='images',
                                      thumbnail={'size': (75, 75)},
                                      extra_thumbnails={'icon': {'size': (25, 25),'options': ['crop', 'upscale']},
                                                        'large': {'size': (200, 400)},
                                                        },
                                    )
    name= models.CharField(maxlength=100)

ImageWithThumbnailsField in sorl-documentation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top