jonasundderwolf / django-image-cropping

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

JQuery loaded, even if IMAGE_CROPPING_JQUERY_URL = None #104

Closed chriscz closed 7 years ago

chriscz commented 7 years ago

Hi there. In the doucmentation it is said that setting

IMAGE_CROPPING_JQUERY_URL = None

should result in django-image-cropping using the existing jQuery library. However I found this not to be the case. There is a null check against image_cropping_jquery_url , however it checks for the string "None" , whereas the actual value is none.

jQuery(function() {
  var image_cropping_jquery_url = jQuery('.image-ratio:first').data('jquery-url');
 // BUG  this is always null
  if (image_cropping_jquery_url == "None") {
    // JQUERY_URL is set to `none`. We therefore use the existing version of
    // jQuery and leave it otherwise untouched.
    jQ = jQuery;
  } else {
  // JQUERY_URL is specified. Image Cropping's jQuery is included in no conflict mode,
    jQ = jQuery.noConflict(true);
    jQ = jQuery;
  }
  jQ(function() {image_cropping.init();});
});

so maybe your intention was to check against "none"?

I discovered this issue while trying to use django-image-cropping in conjunction with django-file-picker

The fix seems simple enough, replace

image_cropping_jquery_url == "None"

with

image_cropping_jquery_url == null

This might be related to issue #103 .

chriscz commented 7 years ago

I've looked at this again, and now I'm not too sure that this bug is in dango-image-cropping. This might be a side effect of one of my other dependencies, since I found that excluding django-file-picker, makes image_cropping work fine, and

image_cropping_jquery_url = "None"

as required. I'm not too sure on why it couldn't be extracted though. And since I've abandoned integrating the two (after an afternoon's worth of difficulty), I can't provide much more information. So feel free to close this issue.

sonarun commented 7 years ago

For me, changing image_cropping_jquery_url to null doesn't fix the issue unfortunately.

I guess it's not related to #103

anrie commented 7 years ago

I can't really reproduce the issue as I am not using django-file-picker (we are about to move the backend to a separate repo for exactly this reason -> https://github.com/jonasundderwolf/django-image-cropping/commit/1047160a276b64ef8f002b764522037a278443fe)

But as we have test that checks if the setting works (https://github.com/jonasundderwolf/django-image-cropping/blob/master/example/tests/test_settings.py#L21) it really sounds like the issue is not on our side and therefore I am closing this issue.