CCK 6.x-2.1
Filefield 6.x-3.0-alpha6
Imagefield 6.x-3.0-alpha4
public download

When adding/editing a node, the uploaded images thumbs don't appear. The image is uploaded alright on the server in sites/default/files, but the file original_filename.jpg.thumb.jpg does not exist. I presume this thumb is supposed to be generated on the fly when the image is being uploaded, but this does not seem to work on my site. Not sure how to go about debugging this, so hopefully someone has encountered this bug. (Could not find it in the issue queue).

EDIT: the watchdog does not complain either.

Comments

eknowlton’s picture

Status: Active » Needs review

I also had this problem. I let it be for the longest time, but just got into it.

After doing some testing, I have come to the conclusion that when I switched the drupal download file system to "private", that the image field thumbnail wasn't getting the attention it needed to be displayed.

It seems like that when the image is uploaded, the image filename ( yourimg.jpg ) and location ( C:\path\to\files\yourimg.jpg ) were set in the {files} table, but the thumbnail was neglected to be recorded in the {files} table as well.

Seems like a simple query to insert the thumbnail into the table would do.
I keep going through the files and I'm not exactly sure where to actually put it. Ha.

My quick fix...

On line 23 of imagefield_file.inc:

   global $user;
   $check = db_query("SELECT * FROM {files} WHERE filepath = '%s'", imagefield_file_admin_thumb_path($file) );
   if(db_affected_rows($check) == 0){
      $filesize = filesize($file->filepath);
      $info = getimagesize($file->filepath);
      db_query("INSERT INTO {files} ( uid, filename, filepath, filemime, filesize, status, timestamp  ) VALUES ( %d, '%s', '%s', '%s', %d, %d, %d )",
	$user->uid, $file->filename.'-thumb.jpg', imagefield_file_admin_thumb_path($file), $info['filemime'], $filesize, 0, time());  
   }

Although, I ran into some issues with the following issue.

------------------------------------------------------------------------------------------------------------------------

Not sure if I should make a seperate issue but....
it seems that if you try to upload a image with the same name as image in the files directory, it renames the image to _#.xxx .
But fails to update the $file object so when $file->filename is passed to the database {files} table, its not the correct filename.

quicksketch’s picture

Status: Needs review » Fixed

The private files bug has been fixed in #301888: Image previews fail to display with private files directory outside of web root. Please open a new issue for the renaming of files. I'd highly recommend trying out the latest development versions (backup first) until the next beta version is released.

j0rd’s picture

I created a module to regenerate thumbs for people who have lost them. I had this issue, so I created the module to recreate my thumbs. Ran it and it seems to have worked.

Imagefield Thumbs Module:
http://drupal.org/node/336264#comment-1379868

antiorario’s picture

Removed my own comment.

antiorario’s picture

Version: 6.x-3.0-alpha4 » 6.x-3.0-beta3
Status: Fixed » Closed (duplicate)