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
Comment #2
annerl commentedComment #3
anybodyThank you @annerl - could you please check if the error still occurs with latest dev?
Comment #4
proweb.ua commentedVersion: 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
Comment #5
balis_m commentedThe issue Image alt/title tag as photoswipe caption not working in entity reference fields also fixes this error.
Could you please check that it works?
Comment #6
anybodyThis 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.
Comment #7
anybody@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!
Comment #8
anybodyClosing this as duplicate of the newer #3271273: Using a media entity reference field in combination with the "Photoswipe" display option throws an error but can't confirm #3258617: Image alt/title tag as photoswipe caption not working in entity reference fields fixed that.
@balis_m could you have another look at the newer issue?