Forums / All Other Contributions/Addons / Attribute image replaces main product image on select [Support Thread]

Attribute image replaces main product image on select [Support Thread]

Views: 44,653

Results 81 to 100 of 177
21 Dec 2016, 3:12 AM
#81
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Attribute image replaces main product image on select [Support Thread]

mc12345678:

Just uploaded version 1.5.6 of this plugin.

Writeup was:

It should be available from the location identified in post 1 of this thread which is here when it has been reviewed and approved by one of the ZC volunteers. (ie. please be patient while the code undergoes the necessary review cycle prior to being made available here.)
Version 1.5.6 of this plugin is available here.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

11 Jan 2017, 4:31 AM
#82
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Submitted version 1.5.7 based on questions asked above and some concepts applied/discussed below:

  • Added "Removal" of most of the javascript code if the admin option to not display attribute images is set to true. This
    is expected to have a positive impact on load speed for such conditions.
  • Modified the approach to the image swap, but left behind the previous code with it commented out. The reason is that
    now instead of returning a newly formatted image (which requires more device communication), the original image is
    "restored" if there is no attribute image assigned.
  • Added some console logging of debug information if the attempt to execute the initialization code fails.

Upon review, acceptance, and posting should be downloadable from here.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

17 Jan 2017, 10:48 PM
#83
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Submitted version 1.5.7 based on questions asked above and some concepts applied/discussed below:

  • Added "Removal" of most of the javascript code if the admin option to not display attribute images is set to true. This
    is expected to have a positive impact on load speed for such conditions.
  • Modified the approach to the image swap, but left behind the previous code with it commented out. The reason is that
    now instead of returning a newly formatted image (which requires more device communication), the original image is
    "restored" if there is no attribute image assigned.
  • Added some console logging of debug information if the attempt to execute the initialization code fails.

Upon review, acceptance, and posting should be downloadable from here.

Version 1.5.7 is now available from here.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jun 2017, 3:01 PM
#84
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Version 1.5.7 is now available from here.

I'm using Zen Cart 1.5.5e - does this module actually work? Can't make head or tail of the installation. Seems a bit messy and nothing happens after installation.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 3:35 PM
#85
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

I'm using Zen Cart 1.5.5e - does this module actually work? Can't make head or tail of the installation. Seems a bit messy and nothing happens after installation.

It does work on ZC 1.5.5e responsive template or not. Looking over the instructions again, they certainly could be clearer and the few lines modified in the admin/options_name_manager.php file could possibly be commented considering how little was changed/added there. For the image swap, there is no SQL necessary. There was some "link" code that was incorporated at one point; however, its design and intent are/were not clear but the code/SQL remained available for anyone that had discovered the "secret" behind it.

What "happen" is expected? What has been done to assign/designate an image to an attribute that is to take the place of the main image? What other javascript is involved? What other image related plugins are installed? What conflicts have been identified?

Basically, other than the few lines of code to be added to the admin/options_name_manager.php, associated language file, and the template override of the attributes.php file to ensure the use/availability of necessary notifiers, for a ZC 1.5.5e system there should be no other override or file replacement. In fact if no other plugin has modified the admin/options_name_manager.php file as provided in ZC 1.5.5e, then the provided file could replace it, with the same said of the admin/includes/languages/english/options_name_manager.php file.

The ajax.php file provided in this plugin should not overwrite the ajax.php file provided in versions of ZC 1.5.5c or above (currently is the same as provided in ZC 1.5.5e), but was what was available at the time of distribution and provided improved operation over the previous ajax related file.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jun 2017, 3:52 PM
#86
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

It does work on ZC 1.5.5e responsive template or not. Looking over the instructions again, they certainly could be clearer and the few lines modified in the admin/options_name_manager.php file could possibly be commented considering how little was changed/added there. For the image swap, there is no SQL necessary. There was some "link" code that was incorporated at one point; however, its design and intent are/were not clear but the code/SQL remained available for anyone that had discovered the "secret" behind it.

What "happen" is expected? What has been done to assign/designate an image to an attribute that is to take the place of the main image? What other javascript is involved? What other image related plugins are installed? What conflicts have been identified?

Basically, other than the few lines of code to be added to the admin/options_name_manager.php, associated language file, and the template override of the attributes.php file to ensure the use/availability of necessary notifiers, for a ZC 1.5.5e system there should be no other override or file replacement. In fact if no other plugin has modified the admin/options_name_manager.php file as provided in ZC 1.5.5e, then the provided file could replace it, with the same said of the admin/includes/languages/english/options_name_manager.php file.

The ajax.php file provided in this plugin should not overwrite the ajax.php file provided in versions of ZC 1.5.5c or above (currently is the same as provided in ZC 1.5.5e), but was what was available at the time of distribution and provided improved operation over the previous ajax related file.

I think the installation has been made into a banquet, not a meal. I just need an image swap facility on attributes. There are sunglasses, each one has different colours, so requires an image swatch of the actual glasses in that colour. That swatch would change the colour of the main product image on either mouseover, tickbox selection, or radio button selection.

Thats all I need :-)

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 4:28 PM
#87
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

I think the installation has been made into a banquet, not a meal. I just need an image swap facility on attributes. There are sunglasses, each one has different colours, so requires an image swatch of the actual glasses in that colour. That swatch would change the colour of the main product image on either mouseover, tickbox selection, or radio button selection.

Thats all I need :-)

This plugin will take the image that is loaded in the attributes controller and make it the main product image in the following conditions:
From options name manager, edit an option name
in: Attribute Style for Radio Buttons/Checkbox: set a value of 6
option name types supported are: checkbox, radio, and dropdown (select).
In the attributes controller for the product, whatever image is provided for a given attribute, that image will replace the main image when the attribute is selected.

Then if an attribute that is selected does not have an image assigned to it the main image is to return back to what it was upon "page load".

If wanted to adapt to an "onhover" or other related javascript action, then that could be incorporated into includes\classes\observers\auto.attrib_image_swap.php file primarily within the function updateNotifyAttributesModuleStartOptionsLoop to use some other event for which to listen. Of course that would also primarily make the on_load file nearly needless if the action requires user to directly interact rather than for a selection to "exist". (Ie. if a product is added to the cart, the cart visited and then the product selected from the cart to return to the product info page, upon return to the product info page, one might expect the image to "match" what was selected without further selecting an option.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jun 2017, 4:32 PM
#88
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

Yes but it didn't work for me.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 5:18 PM
#89
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

Yes but it didn't work for me.

While at the moment I have limited resources to test against the site, perhaps could identify the path to a product where the functionality is expected, including which attribute(s) are to change the look and can get back to you with what is identified.

Basically the review would be to step through the javascript as it was executing (can be done by pressing f12 on a PC keyboard and navigating to the debug related section of the browser) and see what, if any error is being caused, and/or data being transferred to/from the server. As said there may be some other image related plugin that is having a conflict or some other javascript code that is negating the operation of the plugin. It otherwise is a relatively simple bit of code that is involved.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jun 2017, 5:42 PM
#90
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

While at the moment I have limited resources to test against the site, perhaps could identify the path to a product where the functionality is expected, including which attribute(s) are to change the look and can get back to you with what is identified.

Basically the review would be to step through the javascript as it was executing (can be done by pressing f12 on a PC keyboard and navigating to the debug related section of the browser) and see what, if any error is being caused, and/or data being transferred to/from the server. As said there may be some other image related plugin that is having a conflict or some other javascript code that is negating the operation of the plugin. It otherwise is a relatively simple bit of code that is involved.

Unless you want to have a go at installing it yourself? I'm happy to give you FTP access etc through a PM. I may have installed it incorrectly for all I know.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 6:37 PM
#91
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

Unless you want to have a go at installing it yourself? I'm happy to give you FTP access etc through a PM. I may have installed it incorrectly for all I know.

Same "timing" issue applies, but let me know as much detail as can about path or land me as close to the "root" of the store/catalog as possible. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

7 Jun 2017, 6:50 PM
#92
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Same "timing" issue applies, but let me know as much detail as can about path or land me as close to the "root" of the store/catalog as possible. :)

Shall I PM you then?

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 7:14 PM
#93
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

Shall I PM you then?

It's ok I have it working, I will PM you the URL for you to see it as it contains my server IP.

However will try to remember to put a link here when it goes live.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Jun 2017, 8:11 PM
#94
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

Nick1973:

It's ok I have it working, I will PM you the URL for you to see it as it contains my server IP.

However will try to remember to put a link here when it goes live.

Could you elaborate for the other readers about either the issue or what had to be done to "make it work"?

The answer to the other previous question would have been yes. :) But would still be glad to take a look.

On my sample site, I also have the same "issue" that with dropdowns, the possible attribute image(s) remain below the select (dropdown) option. There are ways to make that either more of a feature or to at least have it removed automatically if so desired.

In includes/classes/observers/auto.attrib_image_swap.php if you find this section:

    //  NOTIFY_ATTRIBUTES_MODULE_OPTION_BUILT
    function updateNotifyAttributesModuleOptionBuilt(&$callingClass, $notifier, $products_options_names_fields, &$options_name, &$options_menu, &$options_comment, &$options_comment_position, &$options_html_id, &$options_attributes_image)
    {
        global $products_options;
        
        if ($products_options->RecordCount() == 1 && $products_options_names_fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_LINK) {
            array_pop($options_name);
            array_pop($options_menu);
            array_pop($options_comment);
            array_pop($options_comment_position);
            array_pop($options_html_id);
            //array_pop($options_attributes_image);  // This may need to be commented out because the $options_attributes_image variable is not addressed in the below called function and if it should remain associated with this attribute assignment as part of displaying the information.  
            // With testing, (grid product having a single option value for each of a single option name, one single option value and one multiple option values and in conjunction with another non-grid attribute that displayed a picture.) it didn't seem to matter one way or the other.  
            //   Flow pushes the attribute image to the $options_attributes_image array before coming to this notifier and does so for all attribute types.  
            //   That said, it would seem that if the single option value option type were called upon and that images are in other ways addressed by the below code, then this array item should be popped off the set as well.
            // This could maybe be commented out for 2 reasons: 1) images are not addressed in the below called function, and 2) if they need to be cleared they  will below.
            
            $this->updateNotifyAttributesModuleDefaultSwitch($callingClass, $notifier, $products_options_names_fields, $options_name, $options_menu, $options_comment, $options_comment_position, $options_html_id);
        }
        if ($products_options_names_fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_SELECT) {
            array_pop($options_attributes_image);  // This may need to be commented out because the $options_attributes_image variable is not addressed in the below called function and if it should remain associated with this attribute assignment as part of displaying the information.  
            // With testing, (grid product having a single option value for each of a single option name, one single option value and one multiple option values and in conjunction with another non-grid attribute that displayed a picture.) it didn't seem to matter one way or the other.  
            //   Flow pushes the attribute image to the $options_attributes_image array before coming to this notifier and does so for all attribute types.  
            //   That said, it would seem that if the single option value option type were called upon and that images are in other ways addressed by the below code, then this array item should be popped off the set as well.
            // This could maybe be commented out for 2 reasons: 1) images are not addressed in the below called function, and 2) if they need to be cleared they  will below.
        }

    }

Adding the code in blue above will remove the options_attributes_image "row" from all select lists... Ideally there might be a "switch" added to the configuration window (or another option name selection) that would make that possible or I guess the code could be modified to treat option 7 as allowing image swap in all cases, but not to show the attribute image adjacent to the attribute which would require a little bit of a rewrite to the code besides just modifying the above. (Basically I think it would be to remove all existing cases of '7' from within the observer and in the above check to see if 7 is set and if so, then remove the attribute image from the above selections such that each attribute would know what image to present, but only an image swap would occur..) Maybe that was the original point of those settings... It certainly wasn't clear (to me) before and didn't seem to work in a way that made sense.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

8 Jun 2017, 12:25 PM
#95
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

mc12345678:

Could you elaborate for the other readers about either the issue or what had to be done to "make it work"?

The answer to the other previous question would have been yes. :) But would still be glad to take a look.

On my sample site, I also have the same "issue" that with dropdowns, the possible attribute image(s) remain below the select (dropdown) option. There are ways to make that either more of a feature or to at least have it removed automatically if so desired.

In includes/classes/observers/auto.attrib_image_swap.php if you find this section:

//  NOTIFY_ATTRIBUTES_MODULE_OPTION_BUILT
function updateNotifyAttributesModuleOptionBuilt(&$callingClass, $notifier, $products_options_names_fields, &$options_name, &$options_menu, &$options_comment, &$options_comment_position, &$options_html_id, &$options_attributes_image)
{
    global $products_options;
    
    if ($products_options->RecordCount() == 1 && $products_options_names_fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_LINK) {
        array_pop($options_name);
        array_pop($options_menu);
        array_pop($options_comment);
        array_pop($options_comment_position);
        array_pop($options_html_id);
        //array_pop($options_attributes_image);  // This may need to be commented out because the $options_attributes_image variable is not addressed in the below called function and if it should remain associated with this attribute assignment as part of displaying the information.  
        // With testing, (grid product having a single option value for each of a single option name, one single option value and one multiple option values and in conjunction with another non-grid attribute that displayed a picture.) it didn't seem to matter one way or the other.  
        //   Flow pushes the attribute image to the $options_attributes_image array before coming to this notifier and does so for all attribute types.  
        //   That said, it would seem that if the single option value option type were called upon and that images are in other ways addressed by the below code, then this array item should be popped off the set as well.
        // This could maybe be commented out for 2 reasons: 1) images are not addressed in the below called function, and 2) if they need to be cleared they  will below.
        
        $this->updateNotifyAttributesModuleDefaultSwitch($callingClass, $notifier, $products_options_names_fields, $options_name, $options_menu, $options_comment, $options_comment_position, $options_html_id);
    }

if ($products_options_names_fields['products_options_type'] == PRODUCTS_OPTIONS_TYPE_SELECT) {
array_pop($options_attributes_image); // This may need to be commented out because the $options_attributes_image variable is not addressed in the below called function and if it should remain associated with this attribute assignment as part of displaying the information.
// With testing, (grid product having a single option value for each of a single option name, one single option value and one multiple option values and in conjunction with another non-grid attribute that displayed a picture.) it didn't seem to matter one way or the other.
// Flow pushes the attribute image to the $options_attributes_image array before coming to this notifier and does so for all attribute types.
// That said, it would seem that if the single option value option type were called upon and that images are in other ways addressed by the below code, then this array item should be popped off the set as well.
// This could maybe be commented out for 2 reasons: 1) images are not addressed in the below called function, and 2) if they need to be cleared they will below.
}

}
> Adding the code in blue above will remove the options_attributes_image "row" from all select lists...  Ideally there might be a "switch" added to the configuration window (or another option name selection) that would make that possible or I guess the code could be modified to treat option 7 as allowing image swap in all cases, but not to show the attribute image adjacent to the attribute which would require a little bit of a rewrite to the code besides just modifying the above. (Basically I think it would be to remove all existing cases of '7' from within the observer and in the above check to see if 7 is set and if so, then remove the attribute image from the above selections such that each attribute would know what image to present, but only an image swap would occur..)  Maybe that was the original point of those settings... It certainly wasn't clear (to me) before and didn't seem to work in a way that made sense.

In all honesty I had just installed it incorrectly. I uploaded the files in the instructions but couldn't see any change admin side, however I missed the bit that says 'Attribute Style for Radio Buttons/Checkbox: set a value of 6' - this is in 'Catalog > Option Name Manager'

Attachment 17085

Find the Option Name you want to Edit, then Click 'Edit'


You will then arrive at this screen:

Attachment 17086

From here select: 6= Attribute Image Replaces Main Product Image


I have this working now and for anybody thats interested, if you don't want an attributes image to show next to your Attributes Select Menu, just add the code as described by mc12345678 thats highlighted in blue on the previous post.

I also went a step further, I did not want the 'Larger Image' link so I went and edited zcAttrib_prod_info.php

If you also want to do the same, look in the above file by doing a 'find' or 'search' in the above file for: 

$image_return = '<a href="javascript:popupWindow(\'' . zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'products_image_large_additional=' . $products_image_large) . '\')">' . $image . '<br /><span class="imgLink">' . $larger_text . '</span></a>';

and change to:

$image_return = '' . $image . '';
  } else { // mc12345678 Used to assign an indicate to return to the original image.
    $image_return = "";

this will stop the image from linking to a larger image.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

24 Jul 2017, 7:00 PM
#96
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,449
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

Is this module supposed to show the popup image when clicked? For me it's showing "no image".

IDEASLady
IDEAS Creative Studio

Your image... our business!

24 Jul 2017, 8:45 PM
#97
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

ideasgirl:

Is this module supposed to show the popup image when clicked? For me it's showing "no image".

The file: includes/classes/ajax/zcAttrib_prod_info.php

attempts to load the template override version of the module file typically named: main_product_image.php (referenced by the constant FILENAME_MAIN_PRODUCT_IMAGE) and also provides a link for the file that is referenced/identified by the $products_image_large name. It was verified to work with even Image Handler 4. Now the latest version (under review) also supports the latest version of the ZC plugin called Zen color box and will offer the ability to see the swapped image as a popup as intended via color box.

Plugins that modify associated files may provide different results. Following the guidance of the posting tips when further attempting to address the discrepancy will help to narrow down the source of the issue.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

26 Jul 2017, 9:01 PM
#98
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,449
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

Yes, but never worked. I gave up.

IDEASLady
IDEAS Creative Studio

Your image... our business!

27 Jul 2017, 3:27 AM
#99
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Attribute image replaces main product image on select [Support Thread]

ideasgirl:

Yes, but never worked. I gave up.

Too bad... Haven't been able to get to a computer to possibly review the site, I remember looking at a page from my mobile, but can't remember what link I followed to get there. Also, without knowing anything about the setup, it is not possible to even suggest what may be going on or wrong. So, if there is/was a desire to make it work or identify why it wasn't working in the particular setup, but it worked in a vanilla install of ZC 1.5.5e, then more effort is needed.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

27 Jul 2017, 3:50 AM
#100
IDEASLady avatar

IDEASLady

Totally Zenned

Join Date:
Aug 2005
Location:
Trujillo Alto, Puerto Rico
Posts:
1,449
Plugin Contributions:
3

Re: Attribute image replaces main product image on select [Support Thread]

Yes, don't worry. I was looking for an alternative to my "attributes image popup" since it stopped showing the thumbnails. But I updated the script and now I have it back (which I prefer because the images for attributes will display where they belong).

I really don't know why it didn't work because I don't think there's anything else that could be affecting it.

Keep up the good work! :smartalec:

IDEASLady
IDEAS Creative Studio

Your image... our business!