Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Update image gallery

dominik-zeglen300620f87800
diff --git a/saleor/static/dashboard/js/components/image-gallery.js b/saleor/static/dashboard/js/components/image-gallery.js
index 4ce554aab4..0d67a6d594 100644
--- a/saleor/static/dashboard/js/components/image-gallery.js
+++ b/saleor/static/dashboard/js/components/image-gallery.js
@@ -3,7 +3,7 @@ import Sortable from 'sortablejs';
export default $(document).ready((e) => {
Dropzone.options.productImageForm = {
- paramName: 'image',
+ paramName: 'image_0',
maxFilesize: 20,
previewsContainer: '.product-gallery',
thumbnailWidth: 400,
@@ -33,23 +33,22 @@ export default $(document).ready((e) => {
Sortable.create(el, {
handle: '.sortable__drag-area',
onUpdate: function () {
+ let orderedImages = (function() {
+ let postData = [];
+ $(el).find('.product-gallery-item[data-id]').each(function() {
+ postData.push($(this).data('id'));
+ });
+ return postData;
+ })();
+
$.ajax({
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({
- 'order': (function () {
- let postData = [];
- $(el).find('.product-gallery-item[data-id]').each(function () {
- postData.push($(this).data('id'));
- });
- return postData;
- })()
- }),
+ method: 'POST',
+ url: $(el).data('post-url'),
+ data: {ordered_images: orderedImages},
+ traditional: true,
headers: {
'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()
- },
- method: 'post',
- url: $(el).data('post-url')
+ }
});
}
});