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 '/'
private function join($path, $item)
{
return trim(
$path . ($item ? '/' . ltrim($item, '/') : ''),
'/'
);
}
PHP accepts both \ and / as valid path separators. So just use / in your code.
pub/mediafolder. – Marius Apr 18 '17 at 18:04