[Skip to main content](#vessel-content)

#   hikashop\_child\_image\_active class wrong added to all images

##

- **[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")**
- [![progreccor's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4816.jpg)](/forum/user/4816-progreccor "View progreccor's Profile") Topic Author
- [ Offline](/forum/user/4816-progreccor "Москва")
- SEO, webdesign

Less More

- Posts: 2293
- Thank you received: 314
-
-
-
- [](http://www.d-dd.ru)
-

9 years 3 months ago [\#274684](#274684) by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile")  *[hikashop\_child\_image\_active class wrong added to all images](/forum/3-bug-report/891277-hikashop-child-image-active-class-wrong-added-to-all-images#274684 "-- HikaShop version -- : 3.1.1  I think that many years ago hikashop&#95;child&#95;image&#95;active used to emphases current small image that shows big image on the product page like this:  But later code was broken and at the moment all small images get this class.... (not only that over cursor was).  I have fix this code and so please include it in your distributive. In file show&#95;block&#95;img.php need to change lines:  to")* was created by *[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")*

-- HikaShop version -- : 3.1.1

I think that many years ago **hikashop\_child\_image\_active** used to emphases current small image that shows big image on the product page like this:

[ ![2017-07-25&#95;20-00-06.jpg](/forum/attachment/39412) ](/forum/attachment/39412 "...5&#95;20-00-06.jpg")

But later code was broken and at the moment all small images get this class.... (not only that over cursor was).

I have fix this code and so please include it in your distributive. In file show_block_img.php need to change lines:
Code:

if(thumb_img) { for(var i = thumbs_img.length - 1; i &gt;= 0; i--) { o.addClass(thumbs_img[i], 'hikashop_child_image_active'); } }

to
Code:

if(thumb_img) { o.addClass(thumb_img[0], 'hikashop_child_image_active'); }

---

Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!

- [ ![2017-07-25&#95;20-00-06.jpg](/forum/attachment/39412) ](/forum/attachment/39412 "...5&#95;20-00-06.jpg") [ ](/forum/attachment/39412?download=1 "...5&#95;20-00-06.jpg")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84OTEyNzctaGlrYXNob3AtY2hpbGQtaW1hZ2UtYWN0aXZlLWNsYXNzLXdyb25nLWFkZGVkLXRvLWFsbC1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86564
- Thank you received: 14311
-
-

9 years 3 months ago [\#274695](#274695) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[hikashop\_child\_image\_active class wrong added to all images](/forum/3-bug-report/891277-hikashop-child-image-active-class-wrong-added-to-all-images#274695 "-- HikaShop version -- : 3.1.1  I think that many years ago hikashop&#95;child&#95;image&#95;active used to emphases current small image that shows big image on the product page like this:  But later code was broken and at the moment all small images get this class.... (not only that over cursor was).  I have fix this code and so please include it in your distributive. In file show&#95;block&#95;img.php need to change lines:  to")*

Hi,

Thanks for the feedback on that being broken.
The fix is actually different as far as I could test.
Your patch will always add the hikashop_child_image_active class to the first thumbnail.
The patch should be: Code:

if(thumb_img) { for(var i = thumb_img.length - 1; i &gt;= 0; i--) { o.addClass(thumb_img[i], 'hikashop_child_image_active'); } }

I've tested it on my end and it works fine. We'll include it on our end.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84OTEyNzctaGlrYXNob3AtY2hpbGQtaW1hZ2UtYWN0aXZlLWNsYXNzLXdyb25nLWFkZGVkLXRvLWFsbC1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")**
- [![progreccor's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4816.jpg)](/forum/user/4816-progreccor "View progreccor's Profile") Topic Author
- [ Offline](/forum/user/4816-progreccor "Москва")
- SEO, webdesign

Less More

- Posts: 2293
- Thank you received: 314
-
-
-
- [](http://www.d-dd.ru)
-

9 years 3 months ago -  9 years 3 months ago [\#274709](#274709) by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile")  Replied by *[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")* on topic *[hikashop\_child\_image\_active class wrong added to all images](/forum/3-bug-report/891277-hikashop-child-image-active-class-wrong-added-to-all-images#274709 "-- HikaShop version -- : 3.1.1  I think that many years ago hikashop&#95;child&#95;image&#95;active used to emphases current small image that shows big image on the product page like this:  But later code was broken and at the moment all small images get this class.... (not only that over cursor was).  I have fix this code and so please include it in your distributive. In file show&#95;block&#95;img.php need to change lines:  to")*

You are wrong!
thumb_img is active image (image where user hold cursor of the mouse) and it will always be one! There is no case there two or more active images!

Your patch still working too but there is no need to use "for" loop because it work only one time! from 0 to 0!

See to this line

thumb_img = el.getElementsByTagName('img');

el - is an active element!

thumb_img - is an active image!

There is no need to use for loop!
My patch is working and you can see it in work on two sites!
here [ evastyle.by/odezhda-dlya-devochek/kostyu...ka-shtany-zima-vesna](http://evastyle.by/odezhda-dlya-devochek/kostyum-na-devochku-lada-kurtka-shtany-zima-vesna)

and here [ shop.elino.ru/myaso-tushenoe/product/1-tushenaya-govyadina](http://shop.elino.ru/myaso-tushenoe/product/1-tushenaya-govyadina)

P.S. I also made some improvement so that images changes with fading
Code:

jQuery(target).stop(true,true); jQuery(target).fadeTo(150,.01,function () { target.src = url; } ); jQuery(target).fadeTo(150,1);

---

Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!

Last edit: 9 years 3 months ago by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84OTEyNzctaGlrYXNob3AtY2hpbGQtaW1hZ2UtYWN0aXZlLWNsYXNzLXdyb25nLWFkZGVkLXRvLWFsbC1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26400
- Thank you received: 4080
-
- [](http://obsi.dev)
-

9 years 3 months ago [\#274732](#274732) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[hikashop\_child\_image\_active class wrong added to all images](/forum/3-bug-report/891277-hikashop-child-image-active-class-wrong-added-to-all-images#274732 "-- HikaShop version -- : 3.1.1  I think that many years ago hikashop&#95;child&#95;image&#95;active used to emphases current small image that shows big image on the product page like this:  But later code was broken and at the moment all small images get this class.... (not only that over cursor was).  I have fix this code and so please include it in your distributive. In file show&#95;block&#95;img.php need to change lines:  to")*

Hello,

Just for a manner of speaking, please do not start a message with a "you are wrong !" ; it is unfortunately not very constructive and does not help a peaceful and healthy dialogue.

I don't see why the Nicolas code will be wrong ; it add the desire class.
You need to understand that there is no absolute "wrong" and "right" in development, but you can have more efficient code depending what is your goal.
And the HikaShop goal is flexibility !

So let's image that a user need to have badges on the images ; the Nicolas code could handle the fact that there will be several images.
Even if there is no need to loop for most cases ; thumb_img.length would be " 1 " and there won't have any loop.

I'm really sorry but the Nicolas patch is working and his solution is the right one for the HikaShop coding style.

Best regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84OTEyNzctaGlrYXNob3AtY2hpbGQtaW1hZ2UtYWN0aXZlLWNsYXNzLXdyb25nLWFkZGVkLXRvLWFsbC1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")**
- [![progreccor's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar4816.jpg)](/forum/user/4816-progreccor "View progreccor's Profile") Topic Author
- [ Offline](/forum/user/4816-progreccor "Москва")
- SEO, webdesign

Less More

- Posts: 2293
- Thank you received: 314
-
-
-
- [](http://www.d-dd.ru)
-

9 years 3 months ago -  9 years 3 months ago [\#274813](#274813) by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile")  Replied by *[progreccor](/forum/user/4816-progreccor "View progreccor's Profile")* on topic *[hikashop\_child\_image\_active class wrong added to all images](/forum/3-bug-report/891277-hikashop-child-image-active-class-wrong-added-to-all-images#274813 "-- HikaShop version -- : 3.1.1  I think that many years ago hikashop&#95;child&#95;image&#95;active used to emphases current small image that shows big image on the product page like this:  But later code was broken and at the moment all small images get this class.... (not only that over cursor was).  I have fix this code and so please include it in your distributive. In file show&#95;block&#95;img.php need to change lines:  to")*

I'd like to apologize for how I reacted to the Nicolas post.
I hope you and Nicolas can forgive me...

May be there will be offtopic but I need to explain what I mean and why I wrote what I wrote.

Let's start from the begining:
Nicolas wrote: Code:

Your patch will always add the hikashop_child_image_active class to the first thumbnail.

My code don't add hikashop_child_image_active to the first image.
We talk about a structure like this:
Code:

&lt;a href=""&gt;&lt;img /&gt; &lt;/a&gt; &lt;a href=""&gt;&lt;img /&gt; &lt;/a&gt; &lt;a href=""&gt;&lt;img /&gt; &lt;/a&gt; &lt;a href=""&gt;&lt;img /&gt; &lt;/a&gt; &lt;a href=""&gt;&lt;img /&gt; &lt;/a&gt;

this is "a href" for popup engine. We talk about loop that work with images inside "a" tag.
Inside "a" tag can't be two or more iamges. Hikashop don't add badges to small images. More over - most of popup engines broke if you want to add more that one image inside "a' tag.
So I can't imagine the case where will be more than one image inside any of the "a" tag.

And so I think that Nicolas confuse this code with code for main thumb or may be with previous loop. That's why I wrote my post.

Your code definitely will work but my code will work too. Necessity of the loop in this case don't clear for me.

That all what I want say about it

---

Я не явлюсь официальной службой поддержки!
Я здесь добровольно!

Хочешь получить купон на скидку Hikashop? Спроси меня как!

Last edit: 9 years 3 months ago by [progreccor](/forum/user/4816-progreccor "View progreccor's Profile").

The following user(s) said Thank You: [Jerome](/forum/user/80-jerome "View Jerome's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMtYnVnLXJlcG9ydC84OTEyNzctaGlrYXNob3AtY2hpbGQtaW1hZ2UtYWN0aXZlLWNsYXNzLXdyb25nLWFkZGVkLXRvLWFsbC1pbWFnZXM/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.062 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
