src/Modules/Assets/Asset.php
protected function replaceRelativeLinks($assets_dir)
    {
        $file = fopen($this->getPath(), 'rb');
        $asset_text = fread($file, filesize($this->getPath()));
        fclose($file);

        chdir(dirname($this->getPath()));

        $urls_old = [];
        $urls_new = [];

        preg_match_all('#url\(([\'"]?[^/\'"][^\'"]*[\'"]?)\)#imU', $asset_text, $urls_old);
        $urls = array_unique($urls_old[1]);

        foreach ($urls as $url) {
            $urls_new[] = "'" . PathHelper::toURL(realpath(trim($url, '"\'')), PUBLIC_PATH) . "'";
        }

        $asset_text = str_replace($urls, $urls_new, $asset_text);

        $this->temp_path = $assets_dir . basename($this->getPath());

        if (false === @file_put_contents($this->temp_path, $asset_text)) {
            throw new \RuntimeException('Unable to write file ' . $this->temp_path);
        }
        return $this->temp_path;
    }
protected function replaceRelativeLinks($assets_dir)
    {
        $file = fopen($this->getPath(), 'rb');
        $asset_text = fread($file, filesize($this->getPath()));
        fclose($file);

        chdir(dirname($this->getPath()));

        $urls_old = [];
        $urls_new = [];

        preg_match_all('#url\(([\'"]?[^/\'"][^\'"]*[\'"]?)\)#imU', $asset_text, $urls_old);
        $urls = array_unique($urls_old[1]);

        foreach ($urls as $url) {
            $urls_new[] = "'" . PathHelper::toURL(realpath(trim($url, '"\'')), PUBLIC_PATH) . "'";
        }

        $asset_text = str_replace($urls, $urls_new, $asset_text);

        $this->temp_path = $assets_dir . basename($this->getPath());

        if (false === @file_put_contents($this->temp_path, $asset_text)) {
            throw new \RuntimeException('Unable to write file ' . $this->temp_path);
        }
        return $this->temp_path;
    }
@param string $assets_dir

@return string

@throws \RuntimeException