jonasundderwolf / django-image-cropping

Django helper application to easily and non-destructively crop arbitrarily large images in admin and frontend.
Other
553 stars 131 forks source link

Cropping always hidden in admin #66

Closed tereshkin closed 8 years ago

tereshkin commented 9 years ago

Hi,

Even when I start your example application I don't see cropping field in admin edit page (display: none in HTML). I tried to understand .js code and think, that it happens here: // skip this image if it's empty and hide the whole field, within admin and by itself if (!$image_input.length || $image_input.data('thumbnail-url') === undefined) { $this.hide().parents('div.form-row:first').hide(); return; } In my last project all worked fine but now it doesn't. Can you help me?

tereshkin commented 9 years ago

I've solved my problem only by using older (0.8.2) version.

anrie commented 9 years ago

Which versions of Django and Python are you using?

tereshkin commented 9 years ago

Django (1.7.6) easy-thumbnails (2.2) Pillow (2.7.0)

Python 3.4.2

All works with django-image-cropping (0.8.2) but with (1.0.0) it doesn't.

anrie commented 9 years ago

Sorry, but I can't reproduce this issue.

Did you check the release notes for 0.9 (https://github.com/jonasundderwolf/django-image-cropping#09)? Do you specify a custom jQuery-URL for example and missed the change of the settings name?

Does 0.9 still work or is it only the 0.8 branch that is working for you?

aorzh commented 9 years ago

Has same problem Django (1.7.6) easy-thumbnails (2.2) Pillow (2.7.0)

Python 2.7

I switched to 0.8 version too. I'm not checked 0.9 yet

anrie commented 9 years ago

Just to be clear ... this happens when you check out the latest version from master and use the example app? So neither the modelform example nor the admin examples are working for you? Are there any JavaScript errors showing up in your consoles?

And is the correct version of jQuery included?

By default, if you don't specify an IMAGE_CROPPING_JQUERY_URL, the version specified by Image Cropping should be used.

If you point IMAGE_CROPPING_JQUERY_URL to a jQuery version in your app (like in the example settings) that version should be used.

And if you set IMAGE_CROPPING_JQUERY_URL to None you should be sure that you already included an extra jQuery script. Otherwise things obviously won't work.

aorzh commented 9 years ago

Hi, I installed via pip install Any JS errors in console. I'm not used IMAGE_CROPPING_JQUERY_URL I used cropping not in examples, but in code which is similar. I can switch version and provide you more information, but now I'm busy a little. Regards, Alex

reyiyo commented 9 years ago

Hi! Same problem here!

Django==1.7.7 django-image-cropping==1.0.0

It used to work with older versions

reyiyo commented 9 years ago

Trying version by version, the last working version is 0.8.4... none of 0.8.4+ worked for me

anrie commented 9 years ago

Sorry, but without some specific errors there is hardly anything we can do.

And as all current tests are passing I'd really like to see a new test case that demonstrates the issue.

aorzh commented 9 years ago

hi, anrie. I can provide you more detailed information this week.

X17 commented 9 years ago

This is strange, i created an app a week ago using image_cropping 1.0.1 on localhost it worked smoothly. But today while deploying to production, i installed image_cropping from pip and my cropper field is hidden in admin panel. display:none

Is there something to be done in this case, as i haven't chance a piece of my code.

vaimdev commented 9 years ago

I face the same problem like X17 using image_cropping 1.0.1 . My code works on localhost but deploying to production, the cropper field is hidden. I am using ImageRatioField , and use ForeignField approach. trying to debug in widgets.py or fields.py but no luck. Anybody has idea ?

Python - 2.7.2 Django - 1.7.7

vaimdev commented 9 years ago

Hi all, I have traced the code , and finally found that the problem is not in image_cropping but the missing of jpeg decoder on production server.

The following function return {} due to exception (not able to open jpeg file) , and causing the image does not loaded. Maybe we should throw error message or something in the code.

def get_attrs(image, name): try:

TODO test case

    # If the image file has already been closed, open it
    if image.closed:
        image.open()
    # Seek to the beginning of the file.  This is necessary if the
    # image has already been read using this file handler
    image.seek(0)

    try:
        # open image and rotate according to its exif.orientation
        width, height = pil_image(image).size
    except AttributeError:
        # invalid image -> AttributeError
        width = image.width
        height = image.height
    return {
        'class': "crop-thumb",
        'data-thumbnail-url': thumbnail(image).url,
        'data-field-name': name,
        'data-org-width': width,
        'data-org-height': height,
        'data-max-width': width,
        'data-max-height': height,
    }
except (ValueError, AttributeError, IOError):
    # can't create thumbnail from image
    return {}
anrie commented 9 years ago

Hey vaimdev,

good you found your problem.

Maybe we should throw error message or something in the code.

Yes, that makes sense. I think we should simply check the THUMBNAIL_DEBUG setting from easy_thumbnails. In case it is set to True we simply reraise the original exception so it's clear what caused the problem.

nordbit commented 9 years ago

Do not forgett add:

'cropping'

field to fields list in admin.py

list_display = ('title', 'photo', 'cropping',  'author')

if You are using it. I can confirm, it all works on django==1.8.1 and python==3.4.3