Hi,
When editing a node with one or more attached images, and then using 'preview', no images are shown for the teaser preview, but they are shown for the full node preview. This is similar to the previous problem in #630546: Attached image not shown in edit preview but due to the code-rework it has reappeared and needs to be solved in a slightly different way.
The cause is exactly the same, ie that the array of attached image ids is zero-keyed when viewing the node normally but it is keyed with the iid value during edit. For the teaser, only the first image is required and the function _image_attach_node_load_attached() currently takes $attached_nids[0]. This is empty during node edit. I suggest that using array_shift($attached_nids) will return the desired first iid regardless of how the array is keyed.
The attached screen grabs show the value of $attached_nids in _image_attach_node_load_attached() for the three different scenarios. Patch to follow.
Jonathan
Comments
Comment #1
jonathan1055 commentedHere's a patch against beta6.
Jonathan
Comment #2
jonathan1055 commentedHere is a better screen grab showing the array of image ids used during edit-preview. The call to the full node preview is done first, even though the results of the preview are often shown the other way round, with the teaser preview before the full node preview.
Comment #3
joachim commentedThanks for the patch.
I've committed the attached -- just a few changes to the comments.
#910370 by jonathan1055: Fixed attached image not shown for teaser in preview.
Comment #4
jonathan1055 commentedExcellent.
Thanks Joachim.