Question

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

Était-ce utile?

La solution

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

           })
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top