Great module. Got everything working.
But even after playing around for a week, I could not get the image to display in preview when the cck content is created.
It displays an empty box for the image but no image.
I found that "src" attribute for preview image is set to the image directory under . However no image has been uploaded to this directory. Image is uploaded only when i save the content.
I also found that a file corresponding to the image is created in temp directory.
I am not sure of the mechanism of how, when and where the image is supposed to be uploaded. But from the path generated for the preview image, it does seem that image should have been uploaded to files/image directory when we press upload button.
Any help will be appreciated.
Comment | File | Size | Author |
---|---|---|---|
#16 | imagefield.module-130701.patch | 814 bytes | Darren Oh |
Comments
Comment #1
mr700 CreditAttribution: mr700 commentedsubscribing
Comment #2
quicksketchMarked 119537 and 137577 as duplicates.
Comment #3
quicksketchMarked 111433 as duplicate.
Comment #4
dopry CreditAttribution: dopry commentedDo you have clean urls enabled? Cleanr URL's are required for previews to function.
Comment #5
zigma CreditAttribution: zigma commentedyes. I do have clean url enabled
Comment #6
ricflomag CreditAttribution: ricflomag commentedSame problem here, the bug is reproducible on the most simple Dupal install:
I create an "Imagen" node, type a title and a body, select and upload an image (the thumbnail shows), and press "Preview". The preview only displays the title and the body of the node. The HTML code does not contains any IMG tag.
Let me known if i can provide more details.
Comment #7
drewish CreditAttribution: drewish commentedi'm guessing you're using private file transfers?
Comment #8
ricflomag CreditAttribution: ricflomag commentedNo, i'm using public file tranfer (i've left all Drupal settings on their default value).
Comment #9
ricflomag CreditAttribution: ricflomag commentedI've just tried private files transfers, and didn't notice any change on imagefield preview.
Comment #10
jonahan CreditAttribution: jonahan commented*nod - here too, same problem.
It's weird in that sometimes it works and others it doesn't - no rhyme or reason to it.
I've double-checked permissions and everything.
Comment #11
jonahan CreditAttribution: jonahan commentedOk - I think it has something to do with hook_form_alter, at least in my case.
I commented out a line and it seems to be working. Here's the offending culprit:
$form['form_array'] = array('#value' => '
Comment #12
Darren OhThis continues to be a problem, as reported in duplicate issue 163060. Commenting out the debug statement hasn't fixed it.
Comment #13
Darren OhI now see that this is by design. The module uses the menu system to provide links to files that have not been saved. It cannot provide public file paths unless clean URLs are enabled. Setting the download method to private will make it work without clean URLs.
Comment #14
bobdalob CreditAttribution: bobdalob commentedThis is unattractive, certainly not re-assuring to see this when previewing an image. How do you best hide altogether the 'missing' images when in node preview? Preferable if only temporary.
Comment #15
esolano CreditAttribution: esolano commentedHi zigma. I run into the same problem some time ago. After a lot of research, and digging into the code, I discover this:
When you upload an image and then preview it, it will be stored with a temporary name on your temp Drupal directory (since it has not been saved yet). The script that handles this is the include file.inc. The problem is that there's a php function that creates the temp file with an unique name: tempnam(). This function returns the path where the new file will be temporarily stored. The problem is that between PHP 5.2.2 and PHP 5.2.4 tempnam() changed how it handles the relative path. (check http://php.net/manual/en/function.tempnam.php#78245). So if you have PHP 5.2.4+ then tempnam() will return the full path on your HD; not the relative path; resulting on a broken href on the preview page. That's why it was working on our development site (PHP 5.1.2) but not on our production site (PHP 5.2.4). This is how I solved it (includes/file.inc):I don't know if this is your case... if so, I hope this post help you!
Comment #16
Darren OhOK, more testing shows that this cannot have been by design and is not dependent on the PHP version. The attached patch should fix it for everyone.
Comment #17
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedsubscribing
Comment #18
dopry CreditAttribution: dopry commented@darrenoh, that patch isn't against DRUPAL-5--2... and the menu deals with converting that url to the path to the preview...
@all: open new issues, and your own if you're still having problems. make sure you note which version of imagefield you are using. I'm not sure which issue to address in this thread. I get previews with the latest RC.
Comment #19
Darren OhThis issue is for the DRUPAL-5 branch. It got hijacked in comment #6. Without this patch, the menu system cannot find a match when private downloads are enabled because
file_create_url()
prepends an extra "system/files/" to the URL. This will only affect images uploaded after private downloads are enabled.Comment #20
Darren OhLet me summarize the problems this patch solves:
In both cases, it will be impossible to see the image in the node preview. I do not know if this is an issue in the DRUPAL-5--2 branch, but I will create a separate issue if it is.
Comment #21
32940stf CreditAttribution: 32940stf commentedsubscribing
Comment #22
Darren OhPatch for DRUPAL-5--2 is in issue 230848.
Comment #23
khanshakeeb CreditAttribution: khanshakeeb commentedokay guys i resolve this problem by making tmp dir under drupal files folder like files->tmp...
and then make some changes into imagefield.module simple nothing to do alots of changes and also i recommended never make changes into drupal core files ...
function _imagefield_widget_prepare_form_values($node, $field, &$node_field) {
$fieldname = $field['field_name'];
// clean up the session if we weren't posted.
if (!count($_POST)) {
imagefield_clear_session();
}
// Attach new files
if ($file = file_check_upload($fieldname . '_upload')) {
/* here i take image url which is now in tmp dir */
$img="tmp/".basename($file->filepath);
$file = (array)$file;
if (strpos($file['filemime'],'image') !== FALSE) {
$file = _imagefield_scale_image($file, $field['widget']['max_resolution']);
// Create the filepath for the image preview
$filepath = $img;
/*for the time being i just comment this line */
//file_create_filename($file['filename'], file_create_path($field['widget']['image_path']));
if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
if (strpos($filepath, file_directory_path()) !== FALSE) {
$filepath = trim(substr($filepath, strlen(file_directory_path())), '\\/');
}
$filepath = 'system/files/' . $filepath;
}
$file['fid'] = 'upload';
$file['preview'] = $filepath;
// If a single field, mark any other images for deletion and delete files in session
if (!$field['multiple']) {
if (is_array($node_field)) {
foreach ($node_field as $delta => $session_file) {
$node_field[$delta]['flags']['delete'] = TRUE;
}
}
imagefield_clear_field_session($fieldname);
}
// Add the file to the session
$file_id = count($node_field) + count($_SESSION['imagefield'][$fieldname]);
$_SESSION['imagefield'][$fieldname][$file_id] = $file;
}
}
// Load files from preview state. before committing actions.
if (is_array($_SESSION['imagefield'][$fieldname]) && count($_SESSION['imagefield'][$fieldname])) {
foreach($_SESSION['imagefield'][$fieldname] as $delta => $file) {
$node_field[] = $file;
}
}
}
Comment #24
Darren OhLet me point out that there is a patch in #16 waiting for review. This will not be fixed until someone has tested the patch.
Comment #25
dopry CreditAttribution: dopry commented@darrenOh should be committed now... I didn't test.. so I'm trusting you on this one. :)
Comment #26
minesota CreditAttribution: minesota commentedSubscribing
Comment #27
dopry CreditAttribution: dopry commentedComment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #29
mrfelton CreditAttribution: mrfelton commentedI get the same problem. I tried with the latest 5.x-1.x-dev version as well as 5.x-2.0. The temporary file is created in the location I specified, but the img element on the preview page points to this file with an absolute system url (//home/tom/public_html/drupal-5.x/files/tmp/tmp_Qk22YW) rather than a relative (or even an absolute) web accessible url.
Comment #30
kamleshpatidar CreditAttribution: kamleshpatidar commentedHi mrfelton,
I am facing the same situation
"but the img element on the preview page points to this file with an absolute system url (//home/tom/public_html/drupal-5.x/files/tmp/tmp_Qk22YW) rather than a relative (or even an absolute) web accessible url."
have you find out any solution for this?
Best,
Kamlesh
Comment #31
quicksketchmrfelton and kamleshpatidar: The problem you describe might be because the system does not support Clean URLs. Darren Oh provided a patch for this in #230848: Node Preview Errors, not generating appropriate URLS when rewrite engine off..
Comment #32
quicksketchAlso, the 1.x version is no longer supported. If the problem has been fixed in the latest 2.x version please close.
Comment #33
quicksketchLet's close out this long and winding thread. For any users of 2.6 and higher, a new issue has been opened at #405970: Unsaved nodes: images no longer appear in preview on upgrade to 2.6.
Comment #34
abhisheknagar CreditAttribution: abhisheknagar commentedimage not shown in preview or in content after saving after i upgraded to imagefield-6.x-3.0-beta3