Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions plugins/quant/src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,24 @@ public function sendAttachments($media) {
// Strip query params.
$file = $url = strtok($url, '?');

// Strip the site path from the front of the URL.
if (isset($site->path)) {
$file = preg_replace("#^{$site->path}#", '/', $file);
}

if (isset($item['existing_md5'])) {
// Skip file: MD5 matches.
if (file_exists(ABSPATH . $file) && md5_file(ABSPATH . $file) == $item['existing_md5']) {
continue;
}
}

if (file_exists(ABSPATH . $file)) {
$uploadDir = wp_get_upload_dir();

// Strip the site path from the front of the URL.
if (isset($uploadDir['baseurl'])) {
$basePath = parse_url($uploadDir['baseurl'], PHP_URL_PATH);
$file = preg_replace("#^{$basePath}#", '/', $file);
}

if (file_exists($uploadDir['basedir'] . $file)) {
$attachments[] = [
'file' => $file,
'file' => $uploadDir['basedir'] . $file,
'url' => $url,
];
}
Expand All @@ -256,7 +259,7 @@ public function multipleFiles($files) {

foreach ($files as $file) {
$headers['Quant-File-Url'] = $file['url'];
$path = ABSPATH . $file['file'];
$path = $file['file'];

$requests[] = [
'url' => $this->endpoint . '/file-upload?path=' . $path,
Expand Down