When i upload an image via Imagefield (with is done with ajax), it is not saved with the draft.

Comments

darren.ferguson’s picture

Status: Active » Closed (fixed)

Draft has no ability to save images currently, this is not probably going to be supported in the near future since it would involve determining whether bitcache, file framework, or other uploading mechanizms would be utilized. As of this moment it definitely does not do this for images via the imagefield module.

giorgosk’s picture

Version: 6.x-1.6 » 6.x-1.x-dev
Status: Closed (fixed) » Active

Just tested it with imagefield and draft 6.x-1.x-dev from 2009-Sep-26
and ITS WORKING but with a little glitch

when you are viewing a draft the imagefield does not appear to have been populated since there is no preview image

BUT
saving the module proves to that the imagefield was there

reediting the node will render an image preview as well

and this whole thing makes sense because the image has been saved by the ajax upload code and all the imagefield holds is a reference to it, thus it should work on previous versions as well

There probably needs an extra javascript call to make the preview image showup
Anyone have any idea how to sort this ??

changed status to active since its a little confusing to the user and if we can sort this will be great

giorgosk’s picture

Title: Imagefield not working » Imagefield works correctly but image preview does not appear on VIEW DRAFT

Should have changed title as well

pribeh’s picture

subscribing.

darren.ferguson’s picture

Status: Active » Closed (fixed)

If you want this functionality you will have to utilize hook_draft() and provide a module to do this. This is not a feature of drafts module and the reason the hook_draft() was created was too allow people to add this functionality in their own modules.
Closing since it is not something the draft module can even begin to think handling since there are so many modules and cases and types it would be a never ending job keeping that updated.

pribeh’s picture

Thanks Darren. To help move this forward then:

http://drupal.org/node/699258

pribeh’s picture

Status: Closed (fixed) » Active

Opening again since quicksketch closed the issue over at http://drupal.org/node/699258. Its recommended that Draft provide the support as opposed to the other way around. Any chance Darren?

Best,

Thomas

darren.ferguson’s picture

Status: Active » Closed (works as designed)

Thomas, your best best would be to write a very small module that implements hook_draft only and provides the functionality in imagefield that you are looking for. This is definitely not something that should be in the core draft module because drafts should not know about any other modules it just knows to take the javascript snapshot from the webpage, save in the system then re-load the same javascript snapshot when it is asked for. Any additional help needed for modules should be provided by implementing the hook_draft() functionality.
If you wish to contribute the code as a draft sub module i would gladly add it too the module if not then you can create your own module and page for this functionality.

pribeh’s picture

Great, thanks Darren.

apanag’s picture

The following code worked for me:

/**
 * Implementation of hook_draft().
 */
 
function hook_draft($op, $draft_id, $draft_data = array(), &$form) {

  $img = db_fetch_object(db_query('SELECT * FROM {files} WHERE fid = %d', $draft_data['group_studies(0)(field_study_docs)(fid)']));
  $form['#node']->field_study_docs['0'] = array(
    'fid' => $img->fid, 
    'list' => 1, 
    'uid' => $img->uid, 
    'filename' => $img->filename,
    'filepath' => $img->filepath,
    'filemime' => $img->filemime,
    'filesize' => $img->filesize,
    'status' => $img->status,
    'timestamp' => $img->timestamp,
  );
}