• Hello,

    I am trying to find the best way to edit the settings for prettyPhoto/lightbox in an ‘update safe’ manner. One thing I am trying to do is change the background of the div container from white to black.

    I’ve found that if I edit the core css directly in “plugins\woocommerce\assets\css\prettyPhoto.css”:
    div.pp_woocommerce .pp_content_container { background: #fff; then I can successfully change the background. However when WC gets an update I assume this css file will be overwritten and any changes will be lost. So I tried to duplicate the css file and add it to my theme folder (theme\woocommerce\assets\css\prettyPhoto.css) and then made the same change but it did not have any effect. I was hoping that the ‘template override’ technique would work here.

    Then I found out that prettyPhoto has theme settings that can be edited from within the .js file itself so I proceeded to edit \plugins\woocommerce\assets\js\prettyPhoto\jquery.prettyPhoto.js and from there i changed theme: 'pp_default', to theme: 'dark_rounded', but this had no effect either.

    I also couldnt find anywhere in the WC settings to edit the settings of prettyPhoto so I assume most of this should be done by hand, which is no problem, as long as I know how :).

    If anyone can show me how to properly change the prettyPhoto theme and/or edit the prettyPhoto css in a way thats update-safe, it would be very much appreciated.

    Best.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hyp0xia

    (@hyp0xia)

    no love on this?

    Thread Starter hyp0xia

    (@hyp0xia)

    bump

    Hi there,

    I am looking for an update-safe way to make changes to prettyPhoto also.

    However, I may be able to help explain why the change you made to jquery.prettyPhoto.js had no effect. WooCommerce 2.3.7 uses the minified version of that file to generate the lightbox.

    Make your changes to jquery.prettyPhoto.js, minify it, name it jquery.prettyPhoto.min.js and overwrite the corresponding file. Unfortunately, I don’t think this is update-safe.

    I found an update-safe way to do this.

    First of all, WooCommerce 2.3.7 uses the minified version of jquery.prettyPhoto.js file to generate the lightbox. So, I made my changes to jquery.prettyPhoto.js, minified it, and named it jquery.prettyPhoto.min.js

    I use a child theme so I created a folder in my child theme folder called “custom-js” (you can choose any name) and put my minified file in there.

    Then, in functions.php, I added this code:

    wp_deregister_script('prettyPhoto');
    wp_register_script('prettyPhoto', get_stylesheet_directory_uri() . '/custom-js/jquery.prettyPhoto.min.js' , array( 'jquery' ), '3.1.5', true );
    wp_enqueue_script('prettyPhoto');

    This code deregisters prettyPhoto and then registers and enqueues my version of prettyPhoto.

    If anyone’s interested, here’s my explanation of the wp_register_script function, in this case:

    • 1st parameter: The new script handle. I used the same handle as the old script ‘prettyPhoto’.
    • 2nd parameter: The url of the new script. To get the first part of the url, I used get_stylesheet_directory_uri() which is the correct way, if you have a child theme. The second part of the url is manually typed. A period separates the first and second parts.
    • 3rd parameter: Dependencies of prettyPhoto. I copied this one from woocommerce/includes/class-wc-frontend-scripts.php. In there, prettyPhoto is enqueued using that dependency.
    • 4th parameter: Version of the new script. Same as version of the old one.
    • 5th parameter: true means the script is placed before the </body> end tag. I copied this from woocommerce/includes/class-wc-frontend-scripts.php as well.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change/edit the Lightbox settings (a.k.a prettyPhoto)?’ is closed to new replies.