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
Comment #1
joachim CreditAttribution: joachim commented> 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?
Comment #2
jan_v CreditAttribution: jan_v commentedBecause 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.
Comment #3
joachim CreditAttribution: joachim commented> 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 :)
Comment #4
jan_v CreditAttribution: jan_v commentedSorry 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.
I hope this sheds some light on the situation. Thanks.
Comment #5
joachim CreditAttribution: joachim commentedAh... 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?
Comment #6
jan_v CreditAttribution: jan_v commentedYes, i also noticed that finding a good solution for this is a bit more complicated then i thought.
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
Comment #7
sun#647000: New permissions to attach and view unpublished images sounds closely related. Perhaps this issue can even be marked as duplicate of it.