I try to use PhotoSwipe as field formatter for a gallery of media items, which I combined via the module Media entity slideshow
When I set the field display to 'PhotoSwipe' (/structure/media/manage/gallery/display), I get this message in the backend:

Notice: Undefined index: target_bundles in Drupal\photoswipe\Plugin\Field\FieldFormatter\PhotoswipeFieldFormatter->addEntityReferenceSettings() (line 266 of modules/contrib/photoswipe/src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php).

When I try to open a node with such a media gallery, I get a white screen with the following Error Message:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\media\Entity\Media::getFileUri() in template_preprocess_photoswipe_image_formatter() (line 31 of modules/contrib/photoswipe/photoswipe.theme.inc).

The Error log on the server gives me this message:
[Thu Jul 29 16:47:52.465663 2021] [proxy_fcgi:error] [pid 30802:tid 140236227004160] [client 2.201.252.220:50857] AH01071: Got error 'PHP message: Error: Call to undefined method Drupal\\media\\Entity\\Media::getFileUri() in /var/www/mysite.tld/web/modules/contrib/photoswipe/photoswipe.theme.inc on line 31 #0 /var/www/mysite.tld/web/core/lib/Drupal/Core/Theme/ThemeManager.php(287): template_preprocess_photoswipe_image_formatter(Array, 'photoswipe_imag...', Array)\n#1 /var/www/mysite.tld/web/core/lib/Drupal/Core/Render/Renderer.php(436): Drupal\\Core\\Theme\\ThemeManager->render('photoswipe_imag...', Array)\n#2 /var/www/mysite.tld/web/core/lib/Drupal/Core/Render/Renderer.php(201): Drupal\\Core\\Render\\Renderer->doRender(Array, false)\n#3 /var/www/mysite.tld/web/core/lib/Drupal/Core/Template/TwigExtension.php(450): Drupal\\Core\\Render\\Renderer->render(Array)\n#4 /var/www/mysite.tld/web/sites/default/files/php/twig/61015d6496788_field.html.twig_4AgaIBvZspyP_OOVHQ9KxSWCe/FsXQsFiGgj7UhAez4BM1HaiJTj2sjL4WHprRFMOx4mw.php(125): Drupal\\Core\\Template\\TwigExtension->escapeFilter(Object(Drupal\\Core\\Template\\TwigEnvironment)...'
The website is running on Drupal 9.2.2
We are using Photoswipe Module Version 3.0.0
Can anybody help?

Comments

annerl created an issue. See original summary.

annerl’s picture

Issue summary: View changes
anybody’s picture

Thank you @annerl - could you please check if the error still occurs with latest dev?

proweb.ua’s picture

Version: 3.0.0 and 3.x-dev
drupal 9.3.4
PHP 7.4.27
PHP 8.0.14

in Layout Builder page admin/commerce/config/product-types/default/edit/display/default/layout

Error: Call to a member function getFileUri() on null in Drupal\photoswipe\ImageDTO->__construct() (line 114 of /home/***/modules/contrib/photoswipe/src/ImageDTO.php)

Notice: Trying to get property 'entity' of non-object in Drupal\photoswipe\ImageDTO->__construct() (line 114 of /home/***/modules/contrib/photoswipe/src/ImageDTO.php)

balis_m’s picture

anybody’s picture

Version: 3.0.0 » 3.x-dev
Issue tags: +Needs tests

This issue is blocked by missing test coverage for the photoswipe module.

Please first help to fix #2998694: Write tests for typical use-cases to reproduce this error, create a test and ensure the fix on this for all use-cases.
Hope you understand, we're jumping from one problem into the next as the module is very widely used in different scenarios.

See #2998694: Write tests for typical use-cases and help please. Until that, this issue is blocked.

anybody’s picture

Status: Active » Postponed (maintainer needs more info)

@proweb.ua & @annerl,

as #3258617: Image alt/title tag as photoswipe caption not working in entity reference fields was just fixed in 3.x-dev could you please try the latest 3.x dev version and tell us, if this is also fixed? Then please close this as duplicate. Otherwise, please tell us about the persisting problem. Thanks!

anybody’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)