Project:upload (simple)
Version:master
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hello,

An example:
I create a page, insert an image in it ("try.jpg", via the inline module).
When I create a translation of this page, I have to upload the image again, and another file is created ("try_0.jpg").

I think it would be nice if all the translations of a node "shared" the uploaded files. That is:

I create a page, insert an image.
I create its translation, and the image already appears as an attachment.

Comments

#1

For those who is still interested in any kind of solution for mentioned inconvenience.
I suggest following ...
Assume what you have installed and configured both modules (image and i18n)
Function "image_load" in file image.module should be modified in order to make images appear in translated version of node.
just add next lines at the beginning of function .

/* i18n module should ve installed and properly configured */
  $trid = db_result(db_query('SELECT trid FROM {i18n_node} WHERE nid=%d', $node->nid));
  if ($trid) {
   $snid = db_result(db_query('SELECT nid FROM {i18n_node} WHERE trid=%d and nid<>%d',$trid, $node->nid));
   $result = db_query("SELECT filename, filepath FROM {files} WHERE nid in (%d,%d)", $node->nid, $snid);
  }
  else
  {
   $result = db_query("SELECT filename, filepath FROM {files} WHERE nid=%d", $node->nid);
  }
  /* ***************************************** */

And don't forget to comment native statement which retrieve files for current node.
/*  $result = db_query("SELECT filename, filepath FROM {files} WHERE nid=%d", $node->nid);*/

So the whole function should look like this ...

/**
* Implementation of hook_load
*/
function image_load(&$node) {
/* i18n module should ve installed and properly configured */
  $trid = db_result(db_query('SELECT trid FROM {i18n_node} WHERE nid=%d', $node->nid));
  if ($trid) {
   $snid = db_result(db_query('SELECT nid FROM {i18n_node} WHERE trid=%d and nid<>%d',$trid, $node->nid));
   $result = db_query("SELECT filename, filepath FROM {files} WHERE nid in (%d,%d)", $node->nid, $snid);
  }
  else
  {
   $result = db_query("SELECT filename, filepath FROM {files} WHERE nid=%d", $node->nid);
  }
  /* ***************************************** */

/*  $result = db_query("SELECT filename, filepath FROM {files} WHERE nid=%d", $node->nid);*/
  $node->images = array();
  while ($file = db_fetch_object($result)) {
    $node->images[$file->filename] = $file->filepath;
  }
  // special images
  if (empty($node->images['thumbnail'])) {
    $node->images['thumbnail'] = $node->images['_original'];
  }
  if (empty($node->images['preview'])) {
    $node->images['preview'] = $node->images['_original'];
  }
}