CCK version: 5.x-1.5, public download

When editing a node with an imagefield, I browse and enter the image to upload, then click the upload button. The image uploads successfully, but the image itself does not display. Only a thin gray bar appears.

The image DOES show after the submit button is clicked however.

Comments

juanfe’s picture

I'm seeing the same issue, version 1.30.2.7 of imagefield.module.

I think the problem is in line 393 of imagefield.module compounded with an incorrect handling of the tmp file in preview mode.

When you upload a file, the file is created in the /tmp directory with a gobbledygook name. When you save the node after uploading the file, the file gets moved over to the /files directory and named according to what you uploaded.

The thing is, the imagefield.module lists the path for the preview as pointing to the image in the /files directory, not in the /tmp directory -- and by definition, if it's in preview mode it hasn't been moved over to permanent storage/hasn't been confirmed. So the gray line that displays is the equivalent of the "Page not found" message from Drupal.

This is compounded by the fact that there is what seems to be a bug in line 393 of imagefield.module. The module prepends 'system/files' to the filepath before it is passed to the preview item of the form element. However, upload.module also adds system/files/ to the path for an uploaded item -- meaning that the system component of the path is duplicated and shows up in the source for the preview as
http:///system/files/system/files/image.gif -- which also generates a "page not found"

If you try to pull up that URL directly, nothing will display. If you comment out line 393, the path will resolve properly IF the file is in /files directory -- but will still show up as gray bar because it's referencing a file that doesn't yet exist in the path.

_upload_prepare in upload.module has some code that unmunges the tmp filename for preview. I'm not sure if the code in _imagefield_preview is functioning properly. This is, unfortunately, the extent of my knowledge--I'm just not clear enough on how the module works to debug it further.

Juan Felipe

joetsuihk’s picture

cannot reproduce the problem using either 1.x HEAD or 1.1
on cck 1.5

test on WINXP, apache, mysql, localhost/drupal/
fresh install drupal, nth configured.
created a new content type with just one image field, nth configured except the required fields.

clicked "upload" and the page submit(refreshed), image appear normally
and the image is there.
note that there is nth in /files before "submit", but the HTML shows the image is from /files
after "submit", the image file appear in /files

problem may be from permission of tmp files on *nix OS?

joetsuihk’s picture

hello, some update after i try the issue http://drupal.org/node/159037
by setting the path of images to upload,
if you entered a leading slash to the path, for example, "/images"
will show a gray bar only before submit.

is it the case?

juanfe’s picture

Hi there,

Permissions in my tmp directory are set to world read (running on apache, mysql, *nix).

Using Firefox and Safari, see error in both -- the src="" attribute for the preview image is referring to an image that doesn't exist in the /files directory (but that would after clicking "submit").

Is the image you are uploading to verify one that already exists in /files?

Juan Felipe

platypus media’s picture

This seems to be happening for me as well. Oddly enough, this only happens "sometimes." Some images go up without a problem, while others are impossible to upload. Is there some sort of dependency on the file itself that I'm missing? No matter what I name one of my images (a jpg photo), it will not upload at all, while others, if I keep trying, eventually, it will upload.

Has there been any movement on this bug?

Mike

teagle’s picture

Component: Code » Miscellaneous
StatusFileSize
new39.88 KB

CCK: 5.x-1.5
imagefield: 5.x-1.1
tmp and files permissions: 777
download method: public
imagefield configuration in this content type:
- maximum resolution: 0
- image path within files: tried both images and /images
- custom alt + title: yes
- display in a group
- not required
- not multiple values

I get the same problems with imagefield in a custom content type - both on a localhost version of the site (Win XP + XAMPP + Drupal 5.1) and on the production server. In neither case is Drupal in the root folder.

All was OK at first; then I got an empty preview but the image was ok on the published page; now nothing is OK anymore... screenshot here: http://thomaseagle.com/imagefield_problem.jpg.

Sometimes the preview image shows up in edit mode after I "upload", sometimes I get the grey line of the border but no image, I always get the filename. My temp folder has a few files in it. The photo never goes through to /files/images where it is configured to go, and then on the next reload the node edit page shows imagefield empty.

I even tried uploading the image file by ftp to the right folder (files/images, permission 777) so that it would already be there when imagefield tried to link it, and this ensures that the preview image shows up and enacts the rewrite rule so the new image that's the same as the old one doesn't overwrite, but still the image doesn't appear when published.

In my log files I get "Page Not Found" messages for the images at syntactically correct urls from the referrer node/add/event.

If there's anything else I can do to help, let me know.

p_palmer’s picture

I am also experiencing this issue. I noticed that although the image[preview] markup is output, the actual Only local images are allowed. path is wrong, on my win32 dev system, the path = html path + OS type path; so there is a request for a non existing image at...

http://hbn/files/imagecache/head-preview/C:/apache2triad/temp/tmp2850.tmp

  <div class="content">
    <div class="field field-type-image field-field-image"><div class="field-items"><div class="field-item"><img src="http://hbn/files/imagecache/head-preview/C:/apache2triad/temp/tmp2850.tmp" alt="Water (lilie s).jpg" title="Water (lilie s).jpg"  /></div></div></div>  

notice how two separate path types are concatenated together, maybe this is a bug in the fieldimage_js ??

config...
cck version = "5.x-1.x-dev" -- where, content.info,v 1.2.2.3
imagefield.info,v 1.4.4.1 -- imagefield version = "5.x-2.x-dev"
public files enabled

p_palmer’s picture

just to clarify, this issue arises when the preview button rather than submit is pressed.

ms2011’s picture

Experiencing the same problem, but discovered it was being caused by another module, "Remember Me" which [unintentionally?] clears the $_SESSION after every page load. For details, see: http://drupal.org/node/141418

mykle’s picture

FWIW i'm having the same problem in drupal 5.2 with imagefield 5.x-1.1 . Image doesn't show up after clicking 'upload' or 'preview', but does when clicking 'submit'. i am also unable to upload a user account picture with account pictures enabled. maybe that's a clue?

i don't have Remember Me installed, but i have a lot of modules.

p_palmer’s picture

I dont use 'remember me' and the issue was still present (I removed the preview button). Nice heads up tho, in terms of the session info, when you removed 'remember me', did everything work as expected?

douggreen’s picture

StatusFileSize
new924 bytes

Many of the images in my {files} table have the file_directory_path() prepended to them. In this case, the Only local images are allowed. file path doesn't work. The attached patch strips the redundant file_directory_path() from the path.

trogie’s picture

looks like this last patch is for another module imagecache?

I'm also experiencing the problem that newly uploaded images are _sometimes_ not previewed. I have the impressions that 'smaller' images are previewed while the 'bigger' ones not. I'm trying to see what the exact problem could be.

douggreen’s picture

Doh, sorry, you're right. Please ignore the last patch.

gagarine’s picture

Yeah i have the same issue withe just:
-image filed + ckk
-view

The url as a false target and don't point on the tmp folder... like it's write in the http://drupal.org/node/155726#comment-273743 comment.

jmlane’s picture

Same issue: after upload, not image is displayed, only the grey bar where it should be.

If you look at the HTML generated, the module is apparently looking for the image in the wrong place.
<div class="imagefield-edit-preview"><img width="150" title="" alt="" src="http://xxxx/system/files/system/files/affiliates/englogo.gif"/></div>

The directory I have my images going is "affiliates" in the field configuration. That would put it in the "drupal/sites/xxxx/files/affiliates" folder, which is correct (image gets uploaded to that folder). Public write/read permissions are set as well.

I am running CCK 5.x-1.6-1 and imagefield 5.x-1.1.

carsonh’s picture

Version: 5.x-1.1 » 5.x-2.x-dev

Same issue here- tried all imagefield versions including dev versions - in each case the same.

trogie’s picture

Well, as I said in comment #13. I usualy don't see the previews when I upload bigger pictures then the maximum settings. Recently I've always resized my pictures to 1600x1600 before I upload them (less bandwidth) and never had this problem anymore.

dnbsecrets’s picture

Priority: Normal » Minor
Status: Active » Fixed

there seems a bug with gzip output compression & firefox.
when u output gzipped compressed binary data to firefox.
so that's actually not a bug of drupal or imagefield.
i have the same problems with imagecache also
that outputs also images with php.

baja_tz’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

Problem still exists and is not about compression but in path. So, image is not visible after clicking on upload button and it's path is:
http://my_site/files/pictures/misc27_0.jpg
At this moment image is still in temp directory and in my case has name "tmp4.tmp". After submiting node, image is visible because it's transfered from /temp to /files/pictures directory, named as it suppose to be (misc27_0.jpg) and path is correct. Is it possible to set path to /temp for uploaded images before submiting node especially if we don't know what is the image name in temp directory?
drupal 5.2
imagefield 5.x-2.x
method:private

gmuehl’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Fixed » Active

I've just run into the same problems, for the momemt i've found a bug in the function _imagefield_widget_prepare_form_values which is reproducable. if you use the public download method everything is fine, if you use the private download method this function willl generate a path with /system/files/system/files/ in it.

There is some other kind of Bug which is allready mentioned. The uploaded Picture ist moved to the files-directory too late. The Preview will not work, but if you save the new Node everything is fine.

baja_tz’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev

Confirm that it works with public method.

olalindberg’s picture

Having same error (I think). Any resolution available?

Update: I reinstalled Drupal, Apache, Mysql etc on a new server and my problem went away... Have no idea why though..

moshe weitzman’s picture

Still busted, AFAICT

sunnyjiap3’s picture

It seems that if the file system is set to private, the upload preview won't work.

changjen’s picture

Hi All,

Not sure if you have this fixed or if this is the same problem, but, I was having the following problem --
1. file settings as private
2. hit upload
3. instead of seeing the picture, I see a thin grey line.

I made the following change:

/* 
 * This is a copy of the theme_imagefield_image in imagefield.module
 * The only difference is that in the preview there, it does not seem to be working 
 *   when you turn on private files
 * It is double printing "system/files"
 * This code strips out the double including of it
 */
function phptemplate_imagefield_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
  
  $file = (array)$file;
  if (!$getsize || (is_file($file['filepath']) && (list($width, $height, $type, $image_attributes) = @getimagesize($file['filepath'])))) {
    $attributes = drupal_attributes($attributes);
    
    if ($file['fid'] == 'upload') {
      $path = $file['preview'];
      // remove system/files/ from this path
      // need to keep it because it is used in the menu
      // but when resubmit to get the real url, do not want it
      $path = substr($path, 13);
    }
    else {
      $path = $file['filepath'];
    }
    
    $alt = empty($alt) ? $file['alt'] : $alt;
    $title = empty($title) ? $file['title'] : $title;
    $url = file_create_url($path);
    return '<img src="'. check_url($url) .'" alt="'.
        check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
  }
}

You can see the difference by diffing it with theme_imagefield_image. The only difference is if it is upload, stripping out the system/files/

I seem to see the image now when I hit upload.

esolano’s picture

I have the same problem...

changjen, what you posted is related... that patch works fine after uploading the image using 'Download method' as Private, but when switching back to 'Download method' as public, the image doesn't show anymore. And in both cases the image doesn't appear on the preview page after clicking on the preview button; showing only that gray bar mentioned above.

This is the broken url I get on the preview page:

http://xxx/files/imagecache/100x100//tmp/tmp_qaSOUs

where xxx its my server

If I open the /tmp folder, the temp file tmp_qaSOUs is there... but the url seems to be broken, I don't know why this is happening...

If anyone out there has fixed it, please post how you did it! that would be very helpful!!!

CCK: 5.x-1.5
imagefield: 5.x-1.1
tmp and files permissions: 777
download method: public
imagefield configuration in this content type:

dellis’s picture

I've also noticed this problem--sometimes.

For what it is worth, as Admin user, I get the little gray bar instead of a picture the first time around--if I go through the upload process for a second time, the image always uploads successfully.

If however, I am not an Admin user, when this error shows up (and it only shows up sometimes) the image doesn't get uploaded... and in IE7 instead of the gray bar, I get an image element that is the wrong dimensions and is referencing some non-existent image file (the empty img bordering box with the red "x" in the corner). Non admin users, when this bug occurs are unable to upload the image at all. Most of the time, the images go up without a problem, but only sometimes they have issues....

esolano’s picture

I think I came up with a solution to the preview issue... perhaps not the best; but it works for me (on a Linux distro).

The thing is that when setting the temporary directory to /tmp under Site Configuration -> File System you are telling drupal to use the tmp directory of the OS; and somehow, the preview page can not get to that directory... it doesn't find it, resulting on a broken url; which in my case is:
http://serverx/files/imagecache/100x100//tmp/tmp_1MbkQv
As you can see there, after the 100x100/ it tries to look for the temp image on the /tmp directory of the OS but somehow (don't know why yet) it doesn't find it.

So what I did was change the temporary directory under Site Configuration -> File System to files/tmp telling drupal to use the temporary directory of the drupal installation. The url is now as follows:
http://serverx/files/imagecache/100x100//home/esteban/workspace/serverx/...
The url is still broken, but is because the path of the temp image was set wrong... instead of /home/esteban/workspace/serverx/files/tmp/ (the physical path on my HD), it should be just /files/tmp/ which is the path that drupal recognize.

So after that, on the tpl file where the preview page es rendered, i strip the part that drupal doesn't recognize, resulting on a new path as follows:

  print '<div id="group-creation-preview">';
  //
  // here I create the new path...
  //
  $my_path = $node->field_icon[0]['filepath'];
  $pos = strrpos($my_path, "/files/tmp/");
  $my_new_path = substr($my_path, $pos);
  if ($node->field_icon[0]['filepath']) {
    // print '<div class="group-image">' . theme('imagecache', '100x100', $node->field_icon[0]['filepath']) . '</div>'; 
    print '<div class="group-image">' . theme('imagecache', '100x100', $my_new_path) . '</div>';
  }

The resulting url on the preview page is:
http://serverx/files/imagecache/100x100//files/tmp/tmp_1MbkQv
which is no longer a broken URL... the imagechace module now finds it; resize the temp image to 100x100, and now it finally appears on the preview page.

I hope this long post helps anyone out there! perhaps it would help some more experienced drupal programmer to find the root of the bug and fix it!

floretan’s picture

We recently had the same issue on one of our projects, and it turns out that it's not a bug in imagefield but just a certain behavior that you need to be aware of:

1. In order to work with imagecache, which most people use in combination with imagefield, the temporary files folder must be *inside* of the files directory, like 'files/tmp' (this setting can be adjusted at http://example.com/admin/settings/file-system).

2. When a new image is uploaded, its path is stored under $node->field_icon[1]['filepath'] instead of $node->field_icon[0]['filepath'] as it usually is. So if you are using a custom node template, you need to make sure that you are getting the first element of the array:

  if (!empty($node->field_icon)) {
    // when previewing, if the icon is a new one it is stored with an index of 1 instead of 0
    // reset() returns a pointer to the first element of the array.
    $icon = reset($node->field_icon); 
    print '<div class="group-image">' . theme('imagecache', '100x100', $icon['filepath']) . '</div>'; 
  }
drupalprojects’s picture

Component: Miscellaneous » Code
StatusFileSize
new8.12 KB

I think I've fixed it. See attached file. maybe someone will create a patch, based on it.

robotjox’s picture

hey guys,

none of the above worked for me, but I made some progress with an ugly hack that I submitted to another issue: http://drupal.org/node/215873#comment-714530
Hope somebody can turn it into something decent :)

leokyle’s picture

to me the problem seems to happen only if a new path is given for the image, at the field configuration. Since i didn't really needed it, i just removed the optional path to solve the issue. So it means its some problem when displaying from the optional path. I havent seen the code yet.

dopry’s picture

Status: Active » Closed (fixed)

Ok so everyone has jumped in this issue with a me too.... unless you are absolutely certain you are experiencing the same issue that is being reported open your own issue with details of your setup. i'm closing this issue sense it is too noisy for me to make any sense of it. If you are still having issues with imagefield 1.x-dev, please open an issue of you own with the details of your installation and directions to reproduce your problem.

.darrel.

markDrupal’s picture

Version: 5.x-1.x-dev » 5.x-2.0-rc8
Status: Closed (fixed) » Active

I have experienced this same problem When I upload a new image, a temp file is created in the temp directory, but the gray bar is displayed where the thumbnail should be.
my browser tries to load an image:
http://mark.org/files/market/markc09/NEC_0001.JPG
however that image is not located there.

When I hit the submit button on the node, an image is created at that location and I can reedit the node and the gray bar no longer appears.

parrottvision’s picture

I also only have the problem sometimes. And when I re upload it works. But there are other fields missing in the first save. I have considered it being tmp file or a time out in the save of the content. Tried all the RC including rc8 with no change...

Tim Chan’s picture

I solved this problem by enabling Clean URLs.

First, edit Apache's httpd.conf file (for XAMMP users, it should be in xampp\apache\conf\).
Then delete # in the line "#LoadModule rewrite_module modules/mod_rewrite.so".
Restart Apache.
On your Drupal site, go to Administer/Site configuration/Clean URLs and run the test.
Finally enable Clean URLs and you're done.

parrottvision’s picture

I have clean URL's enabled. Not a fix for me sadly.

dopry’s picture

Status: Active » Closed (fixed)

@all, especially you who posted comments #35->38 read my last comment #34

Do Not Reopen this issue.. get your own!!

shenzhuxi’s picture

fix it by editing php.ini
Change this line
allow_url_fopen = off
to
allow_url_fopen = on

trogie’s picture

and I solved the same issue by removing the trailing slash in the 'Image path' in the configuration of the fields for my content-type with imagefield.

kemi’s picture

I had this same problem and it turns out that my options in .htaccess were preventing me from uploading and seeing images. I had to ask my host to configure it for their server.

wsxian’s picture

I have had the similar problem in that my images would not show - not even my logo!
I tried a lot of things.
I contacted the system admin for our website (our ISP) and he changed the permission on this directory to 755 (err - group permission to execute, read, read)): /drupal/sites/default
That did the trick!
My images, including my logo now show! (my images did import correctly prior to this and were located, along with the logo in /drupal/sites/default/files)

The system admin directed me to this: http://drupal.org/node/34025

kalyan_hb’s picture

I have added and configured the image field for basic page in content types. The image shows as getting uploaded but still my image shows in my front/home page only. The other pages like 'about' or 'portfolio' the image doesnt show. I have got Drupal 7.

I have already done the following:

1. I have added the 'img' tag for 'filtered html' ( input formats)

2. Selected the 'alt' option for the image field option.

3. Also added a destination directory for loading images in manage fields.

Please let me if anybody has any idea how to solve this.

cblackmon’s picture

Issue summary: View changes

For anyone that is having this problem, what worked for me (very similar to #40) was to:

1. Go to my php.ini file

2. Change "allow_url_include = Off" to "allow_url_include = On"