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

dopry - April 30, 2008 - 18:39

@michaelfavia, that would be awesome.. I committed some fixes to it already... to use imagefield_check_directory instead of file_check_directory.

#2

dopry - May 11, 2008 - 23:40
Version:5.x-2.0-rc8» 5.x-2.x-dev

bumping version to dev.

#3

ckng - June 3, 2008 - 07:11

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

kees@qrios - June 4, 2008 - 14:40

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

JohnAlbin - July 10, 2008 - 04:09

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.

AttachmentSize
file_directory_path.patch 1.66 KB

#6

JohnAlbin - July 10, 2008 - 04:10
Status:active» needs review

Review, of course!

#7

torstenzenk - August 30, 2008 - 15:00

This patch works like a charm , thank you !

#8

JohnAlbin - August 30, 2008 - 15:12
Status:needs review» reviewed & tested by the community

Taking the liberty to RTBC based on previous comment.

#9

neclimdul - September 8, 2008 - 07:42

wfm as well. fixed an associated problem where I was getting really old expire headers on the default image. through imagecache.

#10

drewish - September 8, 2008 - 19:29
Status:reviewed & tested by the community» fixed

thanks, committed to DRUPAL-5--2

#11

Anonymous (not verified) - September 22, 2008 - 19:32
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#12

gvanhoof - October 24, 2008 - 15:13

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

mtraherne - January 9, 2009 - 23:58

I'm got the same error. After I received the error I was unable to upload any files.

Any solution on this?

#14

ekrispin - February 13, 2009 - 23:51
Status:closed» active

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

JohnAlbin - February 14, 2009 - 01:00
Status:active» closed

You don't need the patch. The fix has already been included in imagefield.

 
 

Drupal is a registered trademark of Dries Buytaert.