Magento 1.9x Images Not Uploading in Admin – JSON in Syntax Error
We recently had a project where our client wanted to show specific images on Simple Products which were associated within Configurable Products. To save time and money, our first step was to mass import the Simple product photos that were actually unique using the method described (here). After our first pass of importing images, they didn’t show on the Product View Page. This started a troubleshooting process as documented here:
- The Simple Products all worked fine, with the exception of the Image which wouldn't show in Admin or on the public facing website.
- We could upload images via the admin, but they would not show.
- The images were being added to the database but not the file system.
Uncaught SyntaxError: Unexpected token C in JSON at position 347 at JSON.parse (<anonymous>) at String.parseJSON [as evalJSON] (prototype.js:720) at klass.initialize (product.js:49) at new klass (prototype.js:101) at (index):1821
By using the Inspector in the web browser, we were able to cross reference the file system and find the files which were not being parsed.
Then using Linux console we were able to run:
find . -size 0 > zerosize.txt
To create a list of files that were zero file size.
Then we were able to run an sql query to remove entries related to these files
DELETE FROM `catalog_product_entity_media_gallery` where `value` in (pasted list of files)
This allowed Magento to then parse the data into Admin and allowed future image uploads to work.