Incorrect flashvars path when using private file system
| Project: | SWF Tools |
| Version: | 6.x-2.5 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | reviewed & tested by the community |
I am really pleased with the SWFTools setup but have run into a problem when using the private file storage system.
I have created a CCK filefield for users to attach media files to blog posts. I am using the private file storage system. I set this filefield to display using SWFTools with link.
I changed the Media Directory URL setting to http://[mydomain]/system/files using $conf in my site's settings.php file.
$conf = array(
'swftools_media_url' => 'http://wwwdev.catlin.edu/system/files', // No trailing slashes!
);I enabled "Allow SWF Tools to grant access to supported private files," though I don't think it's related to this problem, because the audio file I am testing was uploaded using filefield.
The media player displays correctly, the link underneath the player displays correctly, but the file doesn't load in the player.
Looking at source code, I see the following (substituting [] for some path elements):
<param name="flashvars" value="file_url=http://[mydomain]/system/files//home/web/[myhomedir]/files/blog/admin/[myfile].mp3&autostart=false ...
Checking the files database table, I see that Drupal stores absolute file paths (not URLs) for files stored using the private file storage method. I assume that SWFTools is appending this path to the base path specified in the SWFTools settings.
To test this theory, I copied the HTML code that SWFTools generated, pasted it into the node body, and corrected the file_url param as follows:
<param value="file_url=http://[mydomain]/system/files/blog/admin/[myfile].mp3&autostart=false" ...
With this manual change, the audio file plays as expected! This demonstrates that SWFTools would work with the private file system if it formatted the flashvars param correctly.
Can anyone suggest a patch that would correct this behavior in SWFTools? Or am I missing an admin setting that would correct this behavior?
Many thanks for your help with this and for writing a superb module.

#1
Here is a proposed code fix. This works for our installation, but I don't know whether it could cause problems for other types of configurations.
swftools.module, line 800
// If a remote path is set simply build the appropriate path and returnif ($media_url) {
+ $path = str_replace(file_directory_path(), '', $path); // adjust path if using private file storage
+ return $media_url . $path;
- return $media_url . '/' . $path;
}
#2
I confirm the bug. The proposed fix works. Attached the patch file. Please submit to CVS.