Let's say I've uploaded an image using the "attach new image" dialog, and then I preview the post. Everything looks good; I get a thumbnail and everything. Then I click submit and the attached image disappears. When I go to edit the node again, there's no sign of the image. This only happens when I click Preview. If I just click submit, everything is just fine. What could be the problem? any thoughts?

Thanks!

Comments

drewish’s picture

marked http://drupal.org/node/174162 as a duplicate

drewish’s picture

Version: 5.x-1.4 » 5.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1.31 KB

does this do anything for you?

marcingy’s picture

I've tried it as we were having the same issue (against 5.1.4). It didn't work for me howeverI have made a change which seems to work

case 'update':
      if (isset($node->iid)) {
        db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
		
		if($node->iid > 0 && $node->iid > $_POST['iid']){
			db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
		}else{
	        if ($_POST['iid'] > 0) {
	          db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $_POST['iid']);
	        }
		}
      }
marcingy’s picture

sorry it 5.1.5 we are using

marcingy’s picture

Previous code seemed to cause some issue with new posts. This appears to fix the issue for new nodes:

case 'update':
      if (isset($node->iid)) {
        db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
		
		if(($node->iid > 0) && ($node->iid > $_POST['iid'])){
			db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
		}else{
	        if ($_POST['iid'] > 0) {
	          db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $_POST['iid']);
	        }
		}
      }
      break;
    case 'insert':
      if (isset($node->iid)||$_POST['iid']) {
        db_query("DELETE FROM {image_attach} WHERE nid=%d", $node->nid);
		
		if(($node->iid > 0) && ($node->iid > $_POST['iid'])){
			db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $node->iid);
		}else{
	        if ($_POST['iid'] > 0) {
	          db_query("INSERT INTO {image_attach} (nid, iid) VALUES (%d, %d)", $node->nid, $_POST['iid']);
	        }
		}
      }
      break;
drewish’s picture

Status: Needs review » Needs work

please provide the changes as a patch, it makes it much easier to test and review. see this link for more information on creating patches: http://drupal.org/patch

marcingy’s picture

StatusFileSize
new1.24 KB

patch as requested

drewish’s picture

Status: Needs work » Needs review
StatusFileSize
new3.72 KB

ah, i see what's going on. i think this might be a better way to do it.

marcingy’s picture

I'll give this patch a try later and will let you know if it solves the problem.

marcingy’s picture

It seems to work more or less but on occasions I get an error that the thumbnail can't be scaled. I'll let you know the image size that is causing this issue as I suspect it might be a memory issue on my site.

drewish’s picture

Status: Needs review » Fixed

i went ahead and committed this to HEAD and DRUPAL-5

Anonymous’s picture

Status: Fixed » Closed (fixed)