I have a situation where the image nodes created from the attached images are set to 'unpublished'.

When a user creates content and attaches an image, everything is working like a charm. But after the user has saved the new node and chooses to edit this node. The attached image isn't listed in the image-attach select box (because it has status = 0).
When the user saves his changes, the node is being saved without any images attached.
When i publish the image node before the parent node is editted, everything is working like a charm again. But this is an action that i can't control.

This might be related to #647000: New permissions to attach and view unpublished images, but a new permission seems a bit overkill.

By changing

$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, n.sticky FROM {node} n WHERE n.status = 1 AND n.type = 'image' " . $placeholder . "ORDER BY n.sticky DESC, n.title ASC"), $nids);

To

$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, n.sticky FROM {node} n WHERE n.type = 'image' " . $placeholder . "ORDER BY n.sticky DESC, n.title ASC"), $nids);

This problem is fixed, but i'm not sure if this change has any onther negative effects on image_attach.

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

> I have a situation where the image nodes created from the attached images are set to 'unpublished'.

What's causing them to be creates as unpublished?

jan_v’s picture

Because i've unchecked the "published" checkbox at workflow-settings of the image node.

So that images from users first need to be approved before getting published.

joachim’s picture

> Because i've unchecked the "published" checkbox at workflow-settings of the image node.

Right, that makes sense.

> So that images from users first need to be approved before getting published.

So I guess the question is -- what workflow do you expect or want to have here? If you set all new image nodes to be unpublished, then that is what they are :)

jan_v’s picture

Sorry if i wasn't clear on this, but i expect the images to be unpublished. No problem there, but image_attach only lists published images in the node/edit form.

  • A user attaches an image to a node
  • at this point the image is unpublished (still good)
  • The user chooses to edit the parent node, but there are no images listed at 'attached images' fieldset
  • user saves the node, and the unpublished image gets de-attached

I hope this sheds some light on the situation. Thanks.

joachim’s picture

Issue tags: -unpublished

Ah... now I get it.

Not sure how best to fix this. We probably need to show unpublished images in the fieldset, but all or only the already attached ones, and to whom?

jan_v’s picture

Yes, i also noticed that finding a good solution for this is a bit more complicated then i thought.

  • Only include the unpublished images for the owners of those images is not enough. If the admin edits the parent node to approve it (publish it), he gets the same problem again.
  • Include unpublished images for everybody might be too much. I'm using image_attach with the option to attach existing images disabled, but i can imagine that if you have this option enabled, that you don't want all the unpublished images showing up in there
  • Only include the unpublished already attached images for everyone just might do the trick. At least for me it does.

By disabling the option "attach existing images" and removing "AND status=1" at line 520 (#top of issue), it does just that. Havn't yet tried it with the "attach existing images" enabled

sun’s picture

#647000: New permissions to attach and view unpublished images sounds closely related. Perhaps this issue can even be marked as duplicate of it.