Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Following on from some PHP 5 problems, I think there's a path issue when using private files. I am using private files with the files directory set one directory above the 'Drupal root', ie ../files
.
It seems the $filepath used in this call on line 262:
$image = theme('image',
$file->filepath,
$title,
$title,
array('class' => 'inline')
);
is incorrect for me: it contains ../files/greg_pattillo.jpg
instead of /system/files/greg_pattillo.jpg
. I tried passing the variable through file_create_url()
to no avail - in this case the fully qualified URL - http://paul.leafish.co.uk/system/files/greg_pattillo.jpg
is passed to the theme function and it returns nothing.
Comment | File | Size | Author |
---|---|---|---|
#4 | inline.module.private.patch | 1.06 KB | sun |
Comments
Comment #1
sunI've never tried to use Inline with private files...
Since file_create_url() returns a full URI and we only need a path, it seems we have to deal with private files on our own.
Comment #2
leop CreditAttribution: leop commentedI changed line 275:
$html = l($image, $file->filepath, $attributes, NULL, NULL, FALSE, TRUE);
to
$html = l($image, file_create_url($file->filepath), $attributes, NULL, NULL, FALSE, TRUE);
which did the job, but then, my "files" directory still is below the drupal root. I will move the "files" directory and try it again.
Comment #3
leop CreditAttribution: leop commentedI checked it for both private files within and outside the web directory, and for public files, and in all cases changing line 275 -- as stated in my previous post -- works. (nothing was changed in line 262 and below)
Comment #4
sun@leo_pape: The line you changed only affects the link to the inlined file or image, not the file itself.
As far as I can see, the key for private file support is the function function inline_prepare_file_object(). The file path is already adjusted for node previews there. You might want to apply the current documentation patch to gain more information about what happens where.
By speaking of this, you might try the attached patch.
Comment #5
sunComment #6
pips1 CreditAttribution: pips1 commentedI also would love to be able to get inline images with 'private files' enabled.
@leo_pape: I tested changing that line of code you suggested. The result is that [inline:01] will now place a working link to the attached image (before the code change the link to the image wouldn't work at all), but the image isn't displayed inline. :-(
@sun: I tested applying your patch. Unfortunately, the result doesn't work for me. I get the error message: "warning: getimagesize(system/files//home/username/private/www.example.tld/image_640.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /home/username/drupal-sites/www.example.tld/modules/inline/inline.module on line 438."
Please note (I don't know if this is really relevant): I haven't installed 'imagecache', because the scaling-on-the-fly functionality isn't critical for me and imagecache doesn't currently support 'private files' anyway... just mentioning this for the sake of completeness.
Comment #7
wvengen CreditAttribution: wvengen commentedI'm replacing part of
theme_inline_img
on line 62:by the following to get it working without imagecache:
Comment #8
wvengen CreditAttribution: wvengen commentedoops, that must be
@getimagesize($file->filepath)
insteadComment #9
sunMarking as duplicate of #192586: Private files support