Module doesn't handle private files
jonathan_hunt - January 2, 2008 - 09:48
| Project: | Image Publishing |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
If private files are enabled, the paths provided by API calls such as 'fetch-album-images' are incorrect.
I changed _image_pub_image_baseurl() and _image_pub_get_imagefilename() along the following lines:
function _image_pub_image_baseurl() {
- return _image_pub_base_url() .'/'. variable_get('file_directory_path', 'files') .'/'. variable_get('image_default_path', 'images');
+ if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+ return _image_pub_base_url() .'/system/files/'. variable_get('image_default_path', 'images');
+ }
+ else {
+ return _image_pub_base_url() .'/'. variable_get('file_directory_path', 'files') .'/'. variable_get('image_default_path', 'images');
+ }
}
function _image_pub_get_imagefilename($node, $size = '_original') {
$fname = $node->images[$size];
if (isset($fname)) {
- $imgbase = variable_get('image_default_path', 'images') .'/';
- if (!strncmp($fname, $imgbase, strlen($imgbase))) {
- $fname = substr($fname, strlen($imgbase));
+ if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
+ $fname = basename($fname);
}
+ else {
+ $imgbase = variable_get('image_default_path', 'images') .'/';
+ if (!strncmp($fname, $imgbase, strlen($imgbase))) {
+ $fname = substr($fname, strlen($imgbase));
+ }
+ }
}