Technical resource
Magento :: SyntaxError: expected expression, got ','
Note: This is a historical reference, not a current security baseline. Magento 1 is end-of-life.
Problem description
Image upload is broken in Magento after upgrade to 1.9.3 or SUPEE-8788 patch. The following error is logged in browser console:SyntaxError: expected expression, got ','In HTML source code you can see that one element is missing in media_gallery_contentJsObject variable:
var media_gallery_contentJsObject = new Product.Gallery('media_gallery_content', , {"thumbnail":{"label":"Thumbnail ","field":"product[thumbnail]"},"small_image":{"label":"Small Image ","field":"product[small_image]"},"image":{"label":"Base Image ","field":"product[image]"}});
Cause
The problem is caused by Creare/CreareSEO or CJM/ColorSelectorPlus extensions that override image uploader code.Solution
Creare/CreareSEO
Update app/design/adminhtml/default/default/template/creareseo/catalog/product/helper/gallery.phtml file with the following change:
--- app/design/adminhtml/default/default/template/creareseo/catalog/product/helper/gallery.phtml
+++ app/design/adminhtml/default/default/template/creareseo/catalog/product/helper/gallery.phtml
@@ -96,3 +96,3 @@
//getJsObjectName(); ?> = new Product.Gallery('getHtmlId() ?>', getElement()->getReadonly()):?>nullgetUploader()->getJsObjectName() ?>, getImageTypesJson() ?>);
+var getJsObjectName(); ?> = new Product.Gallery('getHtmlId() ?>', getImageTypesJson() ?>);
//]]>
or re-upload it from https://raw.githubusercontent.com/unxsist/CreareSEO/d5e0f35d21d290e61745d9c16a085b0b945f7fc0/app/design/adminhtml/default/default/template/creareseo/catalog/product/helper/gallery.phtml.
CJM/ColorSelectorPlus
diff app/code/local/CJM/ColorSelectorPlus/blocks/Adminhtml/catalog/product/helper/gallery.phtml
--- app/code/local/CJM/ColorSelectorPlus/blocks/Adminhtml/catalog/product/helper/gallery.phtml
+++ app/code/local/CJM/ColorSelectorPlus/blocks/Adminhtml/catalog/product/helper/gallery.phtml
@@ -160,7 +160,7 @@
diff js/cjm/colorselectorplus/product-update.js js/cjm/colorselectorplus/product-update.js
--- js/cjm/colorselectorplus/product-update.js
+++ js/cjm/colorselectorplus/product-update.js
@@ -21,7 +21,6 @@
newImage.defaultimg = 0;
newImage.removed = 0;
this.images.push(newImage);
- this.uploader.removeFile(item.id);
}.bind(this));
this.container.setHasChanges();
this.updateImages();