Magento 2 – Fix ‘Warning: getimagesize(): Filename Cannot Be Empty’ Error After Switching Theme

image resizingmagento2.2.2product-images

I wanted to start building a theme from scratch & my first step was to create a new theme with "Blank" as a parent. I then browsed a few pages & saw that everything works just fine.
On the next step, I removed the parent from my theme & checked again.
Now, the homepage loads OK (only with no CSS, as expected), but on categories & product pages I get this exception:

Exception #0 (Exception): Warning: getimagesize(): Filename cannot be empty in {Magento-Root-Dir}/vendor/magento/module-catalog/Model/Product/Image.php on line 890
...

Thing I already tried (that didn't solve the problem):
* Reset owner & permissions.
* Removing all the generated stuff (cache, page_cache, view_preprocessed, generation, generated, di, static files, …) & catalog images cache.
* Running all sort of CLI commands like setup:upgrade, setup:static-content:deploy, setup:di:compile, …
* Resizing product images using catalog:images:resize.


* I'm using Magento 2.2.2 with developer mode enabled.
* Environment: Ubuntu 16.04 LTS + Apache/2.4.18 & php7.0.26


— Any Idea??

UPDATE:
During some debugging I discovered that the method getMediaAttributes when called from \Magento\Catalog\Helper\Image on line 191, returns different results for Blank theme than my custom parentless theme. On my theme it's like the product has no images (& it's the same product). Does it ring a bell? So far that's what I found out…

Best Answer

The problem is in /etc/view.xml some sizes are missing, you can use the default file form luma theme and change the image sizes in it and it should work.

Related Topic