Hey there
@Quicksketch: I realize you've addressed this half a million times but I realized (after some debugging my situation is different).
Scenario: We've got tonnes of sites installed (using Aegir) within one Drupal 6 install.
I couldn't (for the life of me) figure out why this was not working properly. I could find the file in the database using drush so it was referenced properly.
BUT then I found a gotcha... although I'm not sure the proper way to deal with this...
/**
* A #filefield_value_callback function.
*/
function filefield_source_imce_value($element, &$item) {
if (isset($item['filefield_imce']['file_path']) && $item['filefield_imce']['file_path'] != '') {
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
$file_path = preg_replace('/^' . preg_quote(base_path(), '/') . '/', '', $item['filefield_imce']['file_path']);
}
else {
$file_path = preg_replace('/^' . preg_quote(url('system/files'), '/') . '/', file_directory_path(), $item['filefield_imce']['file_path']);
}
Notice we are using the base_path() to strip off the leading quote...
I'm getting
* http://www.abc123.com/sites/www.abc123.com/files/01.jpg
But in my db it's
* sites/www.abc123.com/files/01.jpg
So I thought maybe it would make sense to strip out the base_url as well? So...
function filefield_source_imce_value($element, &$item) {
if (isset($item['filefield_imce']['file_path']) && $item['filefield_imce']['file_path'] != '') {
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) {
global $base_url;
$file_path = preg_replace('/^' . preg_quote($base_url, '/') . '/', '', $item['filefield_imce']['file_path']);
$file_path = preg_replace('/^' . preg_quote(base_path(), '/') . '/', '', $file_path);
}
else {
$file_path = preg_replace('/^' . preg_quote(url('system/files'), '/') . '/', file_directory_path(), $item['filefield_imce']['file_path']);
}
Does that make sense if so I can roll it into a patch? But I *wonder* if other folks that still continue to have issues are having that due to the problem of incorrect URL's?
PS - I checked and IMCE is not setting Absolute path btw... turning this on / off has no effect on what's returned...
= What I got installed =
IMCE 2.5
Filefield Source 1.8
Comments
Comment #0.0
ShaneOnABike CreditAttribution: ShaneOnABike commentedUsed the wrong code to display code
Comment #0.1
ShaneOnABike CreditAttribution: ShaneOnABike commentedTypo in code
Comment #1
quicksketchD7 version of this same issue: #2291067: IMCE not displaying all files when called through fileField Sources. Closing out this D6 issue.