Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:12:30+00:00 2026-05-30T02:12:30+00:00

I was searching the web for my question and couldn’t find a clear answeror

  • 0

I was searching the web for my question and couldn’t find a clear answeror any example.

Basically, I want to use sorl and want to resize the source image during the Model save time to resize it down to 640×480 size, so that I don’t end-up storing user’s original 2.5 MB files on the disk. I will then use templatetags to create regular thumbnails out of my source as documented in sorl.

I came across couple of sources refer to use ThumbnailField model field that is supposed to be available in sorl.thumbnail.fields. See the link here. However, in my up-to-date sorl copy from the trunk I don’t see any ThumbnailField or ImageWithThumbnailsField. My attempt to import it in the model fails accordingly. I see these references are old though and wondering whether I can achieve the same with up-to-date sorl.

On the other hand sorl documentation indicates only ImageField from sorl.thumbnail (see here) that does not have any size argument to control the source resizing.

BTW, I see this functionality is available with easy_thumbnail that takes an input parameter source_resize.

Any help will be appreciated!

SUMMARY

I accepted the below answer, however I feel natural sorl support for this use case can be very useful – i.e. adding resize_source param to sorl’s ImageField to allow resizing the source image. Below are two factors why this can be useful in the field:

  1. Not to store user’s huge original images if your app has no need for it. Saving disk space.

  2. Not to spend extra CPU for resizing thumbnails from that huge source images if you don’t have specific extreme high quality reasons. To avoid this one may write nested tags in templates to thumbnail from smaller size images but it can become annoying very soon.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:12:32+00:00Added an answer on May 30, 2026 at 2:12 am

    Sorl’s ImageField that you mention, is just a normal Django ImageField with the added benefit of managing the deletion of cached thumbnails. There’s no resizing done on the initial upload – that’s something you have to implement yourself manually via the view you are using to upload. The docs show how to go about this. You can use sorl in that view to do the actual resize operation itself, using the low level API examlpes

    EDIT

    A quicker alternative is to just resize the image when the model is being saved using sorl. You can do something like the following (completely untested though!)

    from sorl.thumbnail import get_thumbnail
    
    class Foo(models.Model):
        image = models.ImageField(upload_to...)
    
        def save(self, *args, **kwargs):
            if not self.id:
                # Have to save the image (and imagefield) first
                super(Foo, self).save(*args, **kwargs)
                # obj is being created for the first time - resize
                resized = get_thumbnail(self.image, "100x100" ...)
                # Manually reassign the resized image to the image field
                self.image.save(resized.name, resized.read(), True)
            super(Foo, self).save(*args, **kwargs)
    

    this will mean that you will have 2 versions of the same image on disk – one where the django image field decides to save it (upload_to path) and one where sorl thumbnail has saved it’s resized thumbnail. This, along with the fact the image is uploaded and saved twice, are the disadvantages of this approach. It’s quicker to implement though

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spent hours searching the web for an answer to this question... Here's what
I've been searching the web (and S.O.) for a while before asking this question.
In searching the web I came across http://groupaware.mobi/iphone which has a sample iphone navigation
What is the Java equivalent of PHP's $_POST ? After searching the web for
I am searching for a web service which can record the actions done by
I've been searching around the web on how to code syntax highlighting text boxes
I'm building a small web search engine for searching about 1 million web pages
I'm searching for a query for an Excel VBA macro to get a web
I'm attempting to add searching support for my PHP web app using MySQL's FULLTEXT
I've been searching for resources for number recognition in images on the web. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.