models/attachment.php bug with getting attachments on folder-mulit-site installs
-
Today, I finally updated the plugin from version 1.0.7 to 1.1.1. All works well, except the attachments of sub-blogs, all image variations are empty.
The cause: the check if a file exists is done using ABSPATH, concatenated with a substring of the url. However, the subdir in which the blog resides is stripped off during this action.
If the file exists check is necessary, one should use upload-path from the blogsettings, because this variable holds the correct path to the files from ABSPATH. No need to substring the url.
instead of:<br /> $filename = ABSPATH . substr($url, strlen($home) + 1);<br />
better use:
<br /> $upload_dir = wp_upload_dir();<br /> $filename = $upload_dir['path'] .'/'. basename(parse_url($url, PHP_URL_PATH));<br />
[edit]
I’m sorry, I was too hasty with my ‘patch’ because i forgot that $upload_dir[‘path’] returns the current folder if you use month-based subfolders, i’ll search for a better solution
https://www.ads-software.com/plugins/json-api/
- The topic ‘models/attachment.php bug with getting attachments on folder-mulit-site installs’ is closed to new replies.