Discussions

Cloud Zoom hide thumbnail if only one image

Hey, I'm using the cloud zoom image gallery that comes with drupal kickstart. Many of the products only have one image so how do I hide the thumbnail when there's only one option?

Posted: Oct 1, 2014

Comments

Peter Marse on November 13, 2014

Josh,

I can't figure out how to get a Rule to count the number of images in an image field. Can you provide guidance on how to do that?

Thanks!

joshmiller Josh Miller on November 14, 2014

Confirmed that this function was "recently" added to the newest version of Rules (7.x-2.x): https://www.drupal.org/commitlog/commit/4518/0a56a353b403c5370da53b915af...

Look for the condition "List has count" and give it the multi-valued image field to test.

... if you wanted the number of things in a list in the action, I often follow this series of rules actions:

1. Create an integer variable, set to 0
2. Loop over the list you want to count
2b. Optional: Create a component that tests for some property (nodes that are published? line items that have products?) and have it return a integer variable that is equal 1.
3. Calculate a value, add 1 (or if you optionally have a condition component, use the return variable here) to the integer variable from step 1
4. Set a value, set the integer variable to the result
5. Outside and after the loop your integer variable will now have the count of the list.

Note: if you need to count only certain things in a loop, you can create a component that returns 1 if a condition is met (the default will be null or 0). I added the optional 2b to help you see where that would be added.

Josh

Peter Marse on November 14, 2014

No luck, unfortunately. The "list has count" condition appears to have been changed to "List count comparison", but I do not have the option to choose the image field as a data selector for that condition.

EDIT

Here's a CSS workaround:

a.cloud-zoom-gallery.cloud-zoom-processed:only-child {
display: none;
}