0

I want to show product images label with each image on product view page.I found below code on product view page but it's not working.

<?php echo $this->htmlEscape($_product->getImageLabel())?>

I want to show label as caption with each image. Thanks

enter image description here

enter image description here

1 Answer 1

0

I have done this with jQuery script. Add span tag after main image in product view page & add script in js.

jQuery(".gallery img").click(function(){
               var gimgSrc = jQuery(this).attr('src');
               var tarr = gimgSrc.split('/');
               var file = tarr[tarr.length-1];

               var gimgTitle = jQuery(this).attr('title');

            // get main img src
            setTimeout(function(){
                var mainimgSrc = jQuery('.product-image img.product-retina').attr('src');
                var tarrrr = mainimgSrc.split('/');
                var filem = tarrrr[tarrrr.length-1];
                //console.log(file+'------'+filem);

                if(file == filem){
                    jQuery('.product-image span.imgLabel').text(gimgTitle);
                }else{
                    jQuery('.product-image span.imgLabel').text('');
                }

            }, 600);
                // end

           })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.