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

jonathan1055’s picture

Status: Active » Needs review
StatusFileSize
new1.16 KB

Here's a patch against beta6.

Jonathan

jonathan1055’s picture

Here 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.

joachim’s picture

Status: Needs review » Fixed
StatusFileSize
new1.52 KB

Thanks 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.

jonathan1055’s picture

Excellent.
Thanks Joachim.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.