Hi Stefan,
Thank you for reaching out!
I’ve reviewed the issue you mentioned. Based on the behavior, it’s likely caused by a conflict with your current theme, another plugin, or possibly some custom modifications.
To help resolve this, you can try adding the following code snippet to your theme’s functions.php
file. It should fix the problem with the image not closing after being enlarged:
function vwg_custom_photoswipe_script_on_product_page() {
if (is_product()) {
?>
<script>
(function () {
document.addEventListener(
'click',
function (e) {
const isItemClick = e.target.closest('.pswp__item');
const isCloseClick = e.target.closest('.pswp__button--close');
if (isItemClick || isCloseClick) {
setTimeout(function () {
const pswpEl = document.querySelector('.pswp');
if (pswpEl) {
pswpEl.className = 'pswp';
}
}, 100);
}
},
true
);
})();
</script>
<?php
}
}
add_action('wp_footer', 'vwg_custom_photoswipe_script_on_product_page', 100);
Please give this a try and let me know if it resolves the issue. I’d appreciate your feedback so we can ensure everything works smoothly.
Best regards,
Hi Martin,
thank you vor the quick respnce. The issue is solved with our code, thank you ver much.
Another small problem or rather an optical thing. Can the preview image (it does not have the correct aspect ration) be replaced by an icon?
have selected an icon, but it is not displayed
Best
Stefan
Hi Stefan,
I’m glad to hear the issue was resolved – happy we could help!
Regarding your question: unfortunately, there’s no built-in option to replace the preview image with a custom icon. The preview image is automatically generated based on the uploaded video.
Also, if you find a moment, I’d really appreciate it if you could leave a review for the plugin here:
https://wordpress.org/support/plugin/video-wc-gallery/reviews/?filter=5
It would mean a lot and help its development further.
Thanks again and all the best,
Hi Martin,
I have just rated the plugin!
OK, the preview image is generated automatically, but it has the word aspect ratio and that looks strange
best
Stefan
Hi Martin,
on Safari it does not work, it´s realy strange on Safari
Another issue, clicking on any video control shows the full size image of the product
best
Stefan
Safari browser issues are not visible except for the issues you have when you click controls and you open in full screen – your theme most likely causes this. Try this code, add it to the function.php file, it should solve the problem.
add_filter('woocommerce_single_product_zoom_enabled','vwg_disable_zoom_for_video_products',10, 2);
function vwg_disable_zoom_for_video_products($enabled, $product) {
if (!is_product() || !$product instanceof WC_Product) {
return $enabled;
}
$video_url = get_post_meta($product->get_id(), 'vwg_video_url', true);
if (!empty($video_url)) {
return false;
}
return $enabled;
}