Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable single product image effects #18131

Closed
paaljoachim opened this issue Dec 13, 2017 · 12 comments
Closed

Disable single product image effects #18131

paaljoachim opened this issue Dec 13, 2017 · 12 comments

Comments

@paaljoachim
Copy link

@paaljoachim paaljoachim commented Dec 13, 2017

The case.

WooCommerce -> Settings -> Display
there should be a disable box for zoom, gallery and lightbox. Then a checkbox for turn off all effects making the single product image non clickable.

As one might have a good enough image as it is without the need for any extra effects going on with the single product image.

Today I have used the code from here to disable each of the areas:
https://businessbloomer.com/woocommerce-disable-zoom-gallery-slider-lightbox-single-product/

but it still leaves the image clickable. It is just a temporary solution.

@kloon
Copy link
Member

@kloon kloon commented Dec 13, 2017

This functionality is dependant on if a theme adds support for it. We add support for the default themes due to the nature of the product page layout, however, you can disable it by using this code

add_filter( 'current_theme_supports-wc-product-gallery-zoom', '__return_false' );
add_filter( 'current_theme_supports-wc-product-gallery-slider', '__return_false' );
add_filter( 'current_theme_supports-wc-product-gallery-lightbox', '__return_false' );
@paaljoachim
Copy link
Author

@paaljoachim paaljoachim commented Dec 13, 2017

Hi Gerhard

Thanks, but the code you shared did not work for me.
I have been using the below code.

 add_action( 'after_setup_theme', 'bbloomer_remove_zoom_lightbox_theme_support', 99 );
  function bbloomer_remove_zoom_lightbox_theme_support() { 
	remove_theme_support( 'wc-product-gallery-zoom' );
	remove_theme_support( 'wc-product-gallery-lightbox' );
	remove_theme_support( 'wc-product-gallery-slider' );
}

I have also been looking at https://www.worcesterwebstudio.com/remove-link-product-image-woocommerce/ to remove the link from the single product image. So it is not clickable. It would be great to get this working. I can then share it multiple places so that others can also benefit from figuring out how to turn off zoom/slider/lightbox and clickable image. (It sounds like this will not be added directly to WooCommerce.)

@paaljoachim
Copy link
Author

@paaljoachim paaljoachim commented Dec 17, 2017

It would be great to have these code snippets added to https://docs.woocommerce.com/documentation/plugins/woocommerce/woocommerce-codex/snippets/general-snippets/

As disabling the zoom/slider/lightbox and clickable link directly in the product page is something that is useful for a lot of people.

@paaljoachim
Copy link
Author

@paaljoachim paaljoachim commented Dec 18, 2017

Btw I suddenly noticed I do not need the code any longer as today one has to instead add the code:
https://woocommerce.wordpress.com/2017/02/28/adding-support-for-woocommerce-2-7s-new-gallery-feature-to-your-theme/

BUT the featured image in the single product page is still clickable.

@paaljoachim
Copy link
Author

@paaljoachim paaljoachim commented Dec 18, 2017

Bottom line:
zoom/slider and lightbox has been removed and one has to use code to reinsert it. To remove the clickable single product featured image one can use:

.woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
    pointer-events: none;
}
@donnamcmaster
Copy link

@donnamcmaster donnamcmaster commented May 26, 2018

Neither of the above methods worked for me. I have an unsupported theme, so WC is helpfully enabling the gallery options for me. A review of the WC code showed that the function where they are being enabled is called on the template_redirect hook at default priority.

So I tried this and it works:

// disable the magnification zoom in product images
add_action( 'template_redirect', function() {
    remove_theme_support( 'wc-product-gallery-zoom' );
    remove_theme_support( 'wc-product-gallery-lightbox' );
    remove_theme_support( 'wc-product-gallery-slider' );
}, 100 );
@adampatterson
Copy link

@adampatterson adampatterson commented Jul 10, 2018

I am having the same issue Since Woo 3.4 does not require custom themes anymore and will load through the the_content I can't disable the lightbox or the photo zoom.

I did try what @donnamcmaster suggested and it worked for me.

@mithayes
Copy link

@mithayes mithayes commented Jun 26, 2019

Massive thanks to @donnamcmaster for the solution provided above - works perfectly for me AND explains the issue I was having. WC adding the support for my unsupported theme in a different way to how one would normally add it in a theme hence the main solutions that are posted all over the internet didn't work in my case. Lifesaver! Thanks Donna!

@acidhose
Copy link

@acidhose acidhose commented Apr 21, 2020

@donnamcmaster thank you! This worked -- I was going crazy! :)

@mehargags
Copy link

@mehargags mehargags commented Apr 8, 2021

I'm trying what @donnamcmaster advised but it is not working.
Using Elementor + Hello Elementor Theme + Hello Elementor Child theme
adding the said info in the CHILD THEME's function.php

Any pointers ?

@adampatterson
Copy link

@adampatterson adampatterson commented Apr 8, 2021

@mehargags It's been a few years so I don't remember if I solved this or not. I just wanted to check that you have a functions.php plural file and not a function.php singular.

@mehargags
Copy link

@mehargags mehargags commented Apr 8, 2021

yes @adamawesomeface it is very well functions.php... there is no function.php file at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants