Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting thumbnail image on python code #13

Closed
ghost opened this issue Aug 25, 2012 · 8 comments
Closed

getting thumbnail image on python code #13

ghost opened this issue Aug 25, 2012 · 8 comments

Comments

@ghost
Copy link

ghost commented Aug 25, 2012

The documentation only shows how to get a thumbnail image on django template.

I'm trying to display the thumbnails in admin list_display. Is it possible to return the thumbnail image path in python code using the image and cropping fields?

Thank you

@jonasvp
Copy link
Member

jonasvp commented Aug 27, 2012

Good point, I'll add a paragraph to that effect to the docs. Until then: it's actually basic easy_thumbnails code so you'll be able to use the same code as without django-image-cropping: http://easy-thumbnails.readthedocs.org/en/latest/usage/#python

The only difference is the new parameter box. The example from our README would look like this in Python code:

thumbnail_url = get_thumbnailer(yourmodel.image).get_thumbnail({
    'size': (430, 360),
    'box': yourmodel.cropping,
    'crop': True,
    'detail': True,
}).url

@ghost
Copy link
Author

ghost commented Aug 27, 2012

Worked as expected. Thank you so much

@uaimax
Copy link

uaimax commented Dec 4, 2012

But if I don't want to create the thumbnail again.
I just want to get the cropped thumbnail by user (on Admin Widget) on view?

@uaimax
Copy link

uaimax commented Dec 4, 2012

What I did (and I'm sure they must have a better way of doing) to get exactly the thumbnail created by the admin user (without recreating it):
def get_home_thumb(self):
fileName, fileExtension = os.path.splitext(str(self.image))
im = '%s%s%s'% (self.image, '.300x152_q85_crop', fileExtension)
return im

@jonasvp
Copy link
Member

jonasvp commented Dec 4, 2012

Well, if you call get_thumbnailer() with the same options as the admin widget does (https://github.com/jonasundderwolf/django-image-cropping/blob/master/image_cropping/widgets.py#L20), easy-thumbnails just returns the same image again. It will, however, re-create the thumbnail if it disappeared in the meantime.

This is expected behaviour, the thumbnails should always be purgeable since they can easily be recreated from scratch. I'm not sure which problem you're trying to solve by not recreating it - you wouldn't have anything to display in that case.

@uaimax
Copy link

uaimax commented Dec 4, 2012

But as I get the picture that was cut by the user with javascript. (Considering the variables of ImageRatioField)?

@jonasvp
Copy link
Member

jonasvp commented Dec 4, 2012

Well, cropping the image would create a new thumbnail again. I thought that's what you wanted to avoid?

If not, pass the "box" parameter with the cropping value to get_thumbnailer.

@uaimax
Copy link

uaimax commented Dec 4, 2012

I just want to get the image that is already cut by admin.

2012/12/4 Jonas notifications@github.com

Well, cropping the image would create a new thumbnail again. I thought
that's what you wanted to avoid?

If not, pass the "box" parameter with the cropping value to
get_thumbnailer.


Reply to this email directly or view it on GitHubhttps://github.com//issues/13#issuecomment-10999715.

AVISO LEGAL
Esta mensagem contém informação confidencial, protegida por sigilo
profissional, para uso exclusivo do destinatário acima enunciado,
especificamente para essa ocasião.
(Constituição Federal, art. 5º, XII e XIV; Lei nº 8.906/94, art. 7º, II).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants