To save disk space on my site I got used to put preview size 0 by 0 pixels. Thus, preview filepath should become equal to _original filepath -- it was the desired effect and it worked in 4.6.

After the upgrade to 4.7, the preview filepath (in case of 0x0 preview setting) is being set to some strange string with substring "files" in it. After investigating I found that the 'filepath' field for 'preview' filename is set to 'images/files' and doesn't contain image filename at all. Further investigating showed that upon creating new image node, the _image_insert function receives wrong $image argument, when called from hook's implementation image_insert.

The problem is that when we call file_create_path with empty string $image, it returns 'files'. I changed the hook implementation from

 function image_insert($node) {
   foreach ($node->images as $label => $image) {
     _image_insert($node, $label, file_create_path($image));
   }
 }

to

 function image_insert($node) {
   foreach ($node->images as $label => $image) {
     if (!empty($image)) {
       _image_insert($node, $label, file_create_path($image));
     }
   }
 }

and it worked.

Attched is the patch between 2 local copies of image.module.

CommentFileSizeAuthor
preview_0x0.patch403 bytesartem_sokolov

Comments

sun’s picture

Status: Needs review » Closed (won't fix)

Development and support for 4.7.x and 4.6.x has ended. You are strongly advised to upgrade to Drupal 5.x or 6.x.

Marking as won't fix. Feel free to re-open this issue if it still exists in one of the supported releases.