Login

Snippets by peterw

Snippet List

Generate thumbnails on save

This is an override the save method of our Photo model. This new save method essentially takes the image, thumbnails it into our various sets of dimensions (for … in self.IMAGE_SIZES…), and save each one (into its own ImageField) before finally call the overwritten method to save the original image. Yes, the dimensions are hardcoded, and there is currently not a way to regenerate them in different sizes, but one shouldn't be that hard to come up with, because you just could just load each photo object to regenerate, then save it again (or something along those lines). mattpdx helped a lot with figuring out this code.

  • thumbnail
Read More

peterw has posted 1 snippet.