7

I am using Dropzone for image uploads and have noticed 2 issues:

  1. Thumbnail generation for the same image fails in some browsers e.g. for the image attached, the thumbnail is properly generated in chrome, blank in safari and in firefox just a grey background.
  2. In safari, most thumbnails are properly generated, but not for some sizes/aspect ratios. e.g. once again the attached image, if streched horizontally, safari will generate the thumbnail, otherwise not.

Update

I have now established that this is being caused by the "null" param for thumbnail width. Setting it to a value fixes the issue in all browsers. Ideally, I would like to show a thumbnail at its original aspect ratio, but it seems this is failing for certain sizes/browsers as described above.

Is there a fix or workaround for this so that I can show my thumbnails at original aspect ratios?

Dropzone init code:

var photosDropzone = new Dropzone("#photosContainer", { url: "{% url 'ajax_photo_upload_view' %}", maxFilesize: 4, 
    acceptedFiles: 'image/*', addRemoveLinks: true, 
dictRemoveFile:'Delete', thumbnailHeight:160, thumbnailWidth:null, });

enter image description here

RunLoop
  • 20,288
  • 21
  • 96
  • 151

2 Answers2

0

Try using following CSS

.dropzone .dz-default.dz-message {
  opacity: 1;
  -ms-filter: none;
  -webkit-filter: none;
  filter: none;
  -webkit-transition: opacity 0.3s ease-in-out;
  transition: opacity 0.3s ease-in-out;
  background: #fff;
  background-repeat: no-repeat;
  background-position: 0 0;
  position: absolute;
  width: 428px;
  height: 123px;
  margin-left: -214px;
  margin-top: -61.5px;
  top: 50%;
  left: 50%;
  font-size: 20px;
}
.dropzone .dz-preview{
  margin: 0 10px !important;
}

.thumbnail {
  height: 150px;
  width: 150px;
  margin: 10px;

}

.thumbnail img{
  min-height: 100px;
  min-width: 100px;
  height: 100px;
  width: 100px;
}


.dropzone img {
  border-radius: 10px;
  vertical-align: middle;
  min-width: 100px;
  min-height: 100px;
}
Bibek Sharma
  • 3,210
  • 6
  • 42
  • 64
-2

You will probably have to calculate the new width based on the original's aspect ratio and size.

See this other Stack Overflow Q/A for an idea on how to do this:

Algorithm to resize image and maintain aspect ratio to fit iPhone

Community
  • 1
  • 1
Snappawapa
  • 1,697
  • 3
  • 20
  • 42