Author Topic: ALT tag for aditional images  (Read 2996 times)

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
ALT tag for aditional images
« on: October 20, 2010, 19:23:00 pm »
In order to improve our SEO, we'd like to insert ALT tag in our aditional images product.

As far as i've gone, it should be done by
components/com_virtuemart/themes/default/theme.php

somewhere in the code below but i dont know how to do it. Any idea?

    * Builds a list of all additional images
    *
    * @param int $product_id
    * @param array $images
    * @return string
    */
   function vmlistAdditionalImages( $product_id, $images, $title='', $limit=1000 ) {
      global $sess;
      $html = '';
      $i = 0;
      foreach( $images as $image ) {
         $thumbtag = ps_product::image_tag( $image->file_name, 'class="browseProductImage"', 1, 'product', $image->file_image_thumb_width, $image->file_image_thumb_height );
         $fulladdress = $sess->url( 'index2.php?page=shop.view_images&image_id='.$image->file_id.'&product_id='.$product_id.'&pop=1' );
         
         if( $this->get_cfg('useLightBoxImages', 1 )) {
            $html .= vmCommonHTML::getLightboxImageLink( $image->file_url, $thumbtag, $title ? $title : $image->file_title, 'product'.$product_id );
         }
         else {
            $html .= vmPopupLink( $fulladdress, $thumbtag, 640, 550 );
         }
         $html .= ' ';
         if( ++$i > $limit ) break;
      }
      return $html;


ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Re: ALT tag for aditional images
« Reply #1 on: November 16, 2010, 14:44:52 pm »
anyone has idea?

ruben-sp

  • Jr. Member
  • **
  • Posts: 64
Re: ALT tag for aditional images
« Reply #2 on: November 20, 2010, 01:04:44 am »
i found the solution!

i think could be useful this solution:
1-locate the file theme.php file under components\com_virtuemart\themes\default\ (or under the directory of used theme);
2- edit the file and locate the function vmlistAdditionalImages;
3- then locate the code:
$thumbtag = ps_product::image_tag( $image->file_name, class="browseProductImage"'
and replace with:
$thumbtag = ps_product::image_tag( $image->file_name, 'alt="'.substr($image->file_name,46).'" class="browseProductImage"'
thus we can use as alt attribute the name of file; the 46 is related with the fact that the "file_name" contains the entire path "components/com_virtuemart/shop_image/product/filename.jpg", so we want retry only the string "filename.jpg" and use it as alt attribute.
In someway the filename maybe useful enough for SEO.
https://forum.virtuemart.net/index.php?topic=60268.msg224212#msg224212

djrgr

  • Beginner
  • *
  • Posts: 4
Re: ALT tag for aditional images
« Reply #3 on: October 01, 2011, 22:31:19 pm »
Hi, excuse me for bumping up this topic but there is some thing i want to ask.

I want my page title to be the alt tag for the image, or at least the productname+category+sitename...

I have learned that is great for seo...

Can you please alter the code so this would be in effect?

lecer

  • Beginner
  • *
  • Posts: 22
Re: ALT tag for aditional images
« Reply #4 on: October 11, 2011, 17:53:01 pm »
yes it will be great to have in the alt tag :
name of the categorie "highest level" of the product + name of the product