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

  • Home
  • SEARCH
  • 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 9136629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:58:40+00:00 2026-06-17T08:58:40+00:00

I currently generate thumbnails for image uploads by hooking the save method of the

  • 0

I currently generate thumbnails for image uploads by hooking the save method of the model the Filefield is in however, for numerous reasons, this really sucks. It does work though, unlike my earlier experiments with custom upload handlers…

This strike me as the appropriate juncture to create and update a thumbnail BUT I came unstuck trying to find out where the uploaded file would eventually be saved (so I can save the thumbnail to a path based on that). I can get the temp folder path easy enough but that’s no use, I need to know which folder the upload will finally uploaded to, is this possible from here?

class Thumbnailer(TemporaryFileUploadHandler):
    def file_complete(self, file_size):
        self.file.seek(0)
        if not self.content_type is None and 'image' in self.content_type:
            newfile = StringIO()
            img = Image.open( self.file )
            thumb_size = 400,300
            img.thumbnail( thumb_size, Image.ANTIALIAS )
            img.save( os.path.join("THIS PATH IS WHAT I NEED", "thumbs", self.file_name, 'JPEG', quality=80 )
    return super(Thumbnailer, self).file_complete(file_size)

ps: please don’t answer by recommending plug ins and mix-ins for thumb-nailing – I know about and have disregarded all those, for this project at least..

  • 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-06-17T08:58:41+00:00Added an answer on June 17, 2026 at 8:58 am

    file upload handler doesn’t know where the uploaded file will be stored, so if you really have to stick up with custom upload handler you will have to hardcode that path.

    Otherwise, you can:

    • custom view to get a tumbnal (generate thumbnail on first request, just like Sorl does)
    • store that path in settings
    • custom Filefield
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using sorl-thumbnail and have a model. class Entry(models.Model): image = ImageWithThumbnailsField(upload_to='uploads/',
I currently use phpthumb to generate thumbnails for profile pictures. http://phpthumb.gxdlabs.com/ This is my
Currently I generate an URL to a different portlet in this fashion: <liferay-portlet:actionURL var=custom
I'm currently attempting to generate thumbnails of PDFs using Ghostscript (or more specifically GhostscriptSharp
Currently I'm using the BouncyCastle library to generate a certificate. Something like this: X509V3CertificateGenerator
I currently generate XML from my single source of truth and save it as
I am currently trying to generate the creation SQL for my tables based off
Currently I'm using Fluent NHibernate to generate my database schema, but I want the
currently i'm trying to use imagick to generate some images without saving them on
Is there currently a way to generate XML files containing tables compatible with Microsoft

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.