imagefield_default_images directory is hardcoded and seems fto be required but never created
michaelfavia - April 28, 2008 - 19:43
| Project: | ImageField |
| Version: | 5.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
on drupal--5-2 branch, I would like to suggest storing the default images under the specified images directory and would happily patch the module to do so. this will ensure both that the directory exists and keep the data together under 1 folder. comment or suggestions dopry?

#1
@michaelfavia, that would be awesome.. I committed some fixes to it already... to use imagefield_check_directory instead of file_check_directory.
#2
bumping version to dev.
#3
Ver 2.1 & 2.x-dev that uses imagefield_check_directory still has the same problem.
The folder 'imagefield_default_images' has to be manually created.
Also the 'imagefield_default_images' feature seems to break default image for multiple instances of same imagefield as in {node_field_instance}. The default image becomes the same for all instances. Used to work under 2.0-x.
#4
Not sure this is related to the same issue.
In preview modus (edit node) image is not shown, it points to /files/path...
The actual image is stored in /path... outside the files path.
All modules are latest version (2.x branche).
This is probably due to content type importing (cck) from a content type export generated from an older module (1.x branche).
Resubmitting the image fields resolves the problem.
#5
The problem is this bit of code:
// verify the destination exists and is writeable...$dst = file_create_path('imagefield_default_images/'. $filename);
if (!imagefield_check_directory(dirname($dst))) {
file_create_path() checks to see that "imagefield_default_images" is a valid directory in the default files directory. Since the directory has yet to be created, it is NOT, so it returns false. dirname(FALSE) returns "." and imagefield_check_directory(".") returns TRUE. So the code doesn't create the directory and, worse, $dst is set to FALSE.
$dst = 'imagefield_default_images/'. $filename;should fix it.Also, the
unlink($field['default_image']['filepath']);just below that does nothing (except generate a warning) since $field['default_image']['filepath'] is a relative path and unlink() requires a full path.#6
Review, of course!
#7
This patch works like a charm , thank you !
#8
Taking the liberty to RTBC based on previous comment.
#9
wfm as well. fixed an associated problem where I was getting really old expire headers on the default image. through imagecache.
#10
thanks, committed to DRUPAL-5--2
#11
Automatically closed -- issue fixed for two weeks with no activity.
#12
hi john,
i got the following : warning: unlink() [function.unlink]: No such file or directory in /var/www/drupal5/modules/imagefield/imagefield.module on line 177 when setting default image.
i am not sure whether your patch would fix it. if so, how do I install the patch on my server? sorry for the dum question but i am new to drupal and the installation was done by somebody else.
thanks, greg
#13
I'm got the same error. After I received the error I was unable to upload any files.
Any solution on this?
#14
The patch doesn't work for us.
The directory now indeed is created but the default photo does not show when viewing a cck content without any photo uploaded for this field.
#15
You don't need the patch. The fix has already been included in imagefield.