On our fresh installed Magento 2.2.4, we created a new product and uploaded images.

The product images are displayed well on category overview, but not on the productpage.

The loading gif is keeping displayed and images are not loaded. Also the tabs are broken, so it seems to be a JS error.

In the browser console we get the following JS error:

Uncaught SyntaxError: Unexpected number in JSON at position 146
    at JSON.parse (<anonymous>)
    at getData (main.js:58)
    at Array.map (<anonymous>)
    at HTMLDocument.apply (main.js:74)
    at fire (jquery.js:3232)
    at Object.add [as done] (jquery.js:3291)
    at jQuery.fn.init.jQuery.fn.ready (jquery.js:3542)
    at jQuery.fn.init (jquery.js:2967)
    at new jQuery.fn.init (jquery-migrate.js:225)
    at jQuery (jquery.js:75)


The problem was occurred by the product name, the product name contains the sign ' which broken the JSON string. Is there a way to solve this?

How can we solve this?

1 Answer 1


We should run the catalog images command: php bin/magento catalog:images:resize.

Situations where this could be necessary might be:

  • After you import products, which might have images of various sizes
  • If images were resized or deleted manually from cache

Each image assigned to a product must be resized in accordance with image metadata defined in a module’s view.xml configuration file. After resizing an image, its resized copy is stored in the cache (/pub/media/catalog/product/cache directory). Magento serves storefront images from cache.

  • Thanks a lot! I already tried that, but it does not work. Problem is still there. It really looks like a JS problem.
    – JGeer
    Jun 11, 2018 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.