I was facing this issue in Magento 2.1.6. The problem was I installed Magento 2 version 2.1.6 with sample data. And all things did go well in setup no errors. After setup, In frontend, my product images were not showing up. I search for it and I read somewhere that running this command will solve my problem.

php bin/magento catalog:images:resize

But it was giving me this error :

Error filtering template: Unable to write file into directory \c:/xampp/htdocs/root/pub/media/catalog/product\cache\2eaddfd0be171511b8beb7c8a6c1c63e\/c/v. Access forbidden.

And I found a solution for this also. And it is as below.

Go to root/vendor/magento/module-catalog/Model/View/Asset/Image.php.

In this file, you need to replace this `DIRECTORY_SEPARATOR`  with `’/’`. Yes, you need to replace this on the whole file. Then find this function getRelativePath() replace it with this

private function getRelativePath($result)
{
    $prefix = $result == '/' ? $result : '';
    $result = $this->join($result, $this->getModule());
    $result = $this->join($result, $this->getMiscPath());
    $result = $this->join($result, $this->getFilePath());
    return $prefix . $result;
}

This helped me. And my problem was solved. Maybe this can help you also.

Be kind to one another. Take care!

No Comments

Post A Comment