I'm using the photoswipe module in a D8.1 installation and love it!
However, I build my pages with paragraphs, therefor I never have my image fields attached to the node itself but the paragraph entity (the paragraph is being attached to a node via a entity reference field).

When calling my pages, I get then following error:
Notice: Trying to get property of non-object in template_preprocess_photoswipe_image_formatter() (line 81 of photoswipe.theme.inc).

It's caused when setting the caption variable, the module always expects a node as host entity.
I've changed the naming from $node to $entity and added a new $node variable which is being set by \Drupal::routeMatch()->getParameter('node');.

I will upload a patch which fixes the mentioned issue, feel free to comment on it and test it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpacassi created an issue. See original summary.

dpacassi’s picture

See attached my patch.

ParisLiakos’s picture

Nice, but this probably does not work when the node is viewed in another page, like a teaser eg where the route match will return no result.

Anybody’s picture

Status: Active » Postponed (maintainer needs more info)

Please retry with the latest dev!

Anybody’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Postponed (maintainer needs more info) » Fixed

Please try the latest 2.x version. It already contained a fix to use the parent instead of the node. I now also renamed the variable to better explain that.

Anybody’s picture

  • Anybody committed 0f32c49 on 8.x-2.x
    Changed $node to parent $entity. Issue #2712261 by dpacassi, Anybody:...

Status: Fixed » Closed (fixed)

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