magento2: [Urgent]Big Problem in Magento 2.1.6 Can't Create Re-size Image In Window 7 - Xampp

Hi Everyone, I just Updated my site to Magento 2.1.6 in local but I have the problem with image re-size. Here my issue when I turn on the “Developer” Mode

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

I’m tried to clean all var and pub folder but not a success.

I’m using the Window 7 and Xampp Server. Please help me resolved this issue.

Best Regards, Ziven.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 20 (3 by maintainers)

Most upvoted comments

Try 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;
}

And You can replace all DIRECTORY_SEPARATOR to ‘/’ in this file.

there is a simple way to solve this issue: in vendor/magento/module-catalog/Model/View/Asset/Image.php:226 remove the ‘DIRECTORY_SEPARATOR’ private function getRelativePath($result) { $result = $this->join($result, $this->getModule()); $result = $this->join($result, $this->getMiscPath()); $result = $this->join($result, $this->getFilePath()); return $result; }

and: /vendor/magento/module-catalog/Model/View/Asset/Image.php:130 replace DIRECTORY_SEPARATOR to ‘/’

PHP accepts both \ and / as valid path separators in all OS. So just use / in your code.

Thanks for fixing. I installed 2.1.7 with sample data and I got into issue , once I run bin/magento catalog:images:resize it solved it . But I was on Ubuntu but this helped.