backslash issue for windows systems
-
Hi,
I am using a window system and setup a site locally, the main issue is the URL replace, as the window uses backslash for path so the function is unable to replace it here in
wp_media.class.php
for the$this->options['local_path']
if uses backslash it gives double backslash. So it wont replace the path for wp-content.To fix this I uses a custom line
$localPath = str_replace('\\\\', '\\', $this->options['local_path']);
public function url_handler($url) { $localPath = str_replace('\\\\', '\\', $this->options['local_path']); $uploadDir = str_replace($localPath, "", $this->uploadDir["path"]); $uploadDir = preg_replace("/\/\d{4}\/\d{2}/", "", $uploadDir); preg_match("/(\/\d{4}\/\d{2}\/.+$)/", $url, $matches); $s3_path = preg_replace(["/[\/]+/", "/^\//"], ["/", ""], $uploadDir . "/" . $matches[1]); $url = $this->options["s3_url"] . $s3_path; return $url; }
- The topic ‘backslash issue for windows systems’ is closed to new replies.