Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Add Auto Product Title As Alt Tag To Empty Images Alt Tag Rate Topic   * * * * * 2 votes

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1191 posts

Posted 15 September 2014 - 11:41 AM #1

*
POPULAR

Hi friends,

After reading http://forum.cs-cart...-product-images i come with a different solution to this issue, product images ALT tag that is missing from many cs-cart online stores.

This solution is for CS-Cart 4.x and I will use My Changes add-on and hooks to survive also on futures upgrades ;)

Please add:

1.
#file
app/addons/my_changes/init.php
#content
<?php
if ( !defined('BOOTSTRAP') ) { die('Access denied'); }
fn_register_hooks(
'get_product_data_post',
'gather_additional_products_data_post'
);

2.
#file
app/addons/my_changes/func.php
#content
<?php

if ( !defined('BOOTSTRAP') ) { die('Access denied'); }
use Tygh\Registry;
function fn_my_changes_get_product_data_post(&$product_data, $auth, $preview, $lang_code){
if(AREA=='C'){
  if(!empty($product_data['main_pair'])){
   if(empty($product_data['main_pair']['detailed']['alt'])){
	$product_data['main_pair']['detailed']['alt'] = $product_data['product'];
   }
  }
  if(!empty($product_data['image_pairs'])){
   foreach ($product_data['image_pairs'] as $key => $value) {
	if(empty($value['detailed']['alt'])){
	 $product_data['image_pairs'][$key]['detailed']['alt'] = $product_data['product'];
	}
   }
  }
}
}
function fn_my_changes_gather_additional_products_data_post($product_ids, $params, &$products, $auth){
if(AREA=='C'){
  foreach ($products as $key => $product_data) {
   if(!empty($product_data['main_pair'])){
	if(empty($product_data['main_pair']['detailed']['alt'])){
	 $products[$key]['main_pair']['detailed']['alt'] = $product_data['product'];
	}
   }
   if(!empty($product_data['image_pairs'])){
	foreach ($product_data['image_pairs'] as $k => $value) {
	 if(empty($value['detailed']['alt'])){
	  $products[$key]['image_pairs'][$k]['detailed']['alt'] = $product_data['product'];
	 }
	}
   }
  }
}
}

You can test it here:

Category: http://www.hungryweb...ags-and-carts/

Product Details: http://www.hungryweb...t-cart-bag.html


I hope that helps,

---
Valentin
part of hungryweb.net

Edited by Vali, 16 September 2014 - 05:50 PM.


 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1416 posts

Posted 15 September 2014 - 12:49 PM #2

*
POPULAR

Super Valentin,

and with your permission, here is the package as Addon for those who don't want to get there hands dirty!

Attached File  auto_alt.zip   1.63KB   156 downloads
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 16 September 2014 - 12:36 PM #3

Dear Vali,

app/addons/my_changes/ini.php

Please correct your message and change the file name to init.php. It can confuse CS-Cart users who is not familiar with the add-ons

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1416 posts

Posted 16 September 2014 - 12:45 PM #4

You are right ecomLabs to mention this.

I forgot to mention that, as I have corrected in the addon package.

Fotis
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • Hungryweb
  • Senior Member
  • Authorized Reseller
  • Join Date: 10-Feb 12
  • 1191 posts

Posted 16 September 2014 - 05:51 PM #5

Dear Vali,

app/addons/my_changes/ini.php

Please correct your message and change the file name to init.php. It can confuse CS-Cart users who is not familiar with the add-ons

Done, thank you ;)

 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 903 posts

Posted 06 June 2015 - 03:33 PM #6

helloo... it seems that this addon is working on 4.3.1

 

Posted 06 June 2015 - 06:18 PM #7

What a awesome add-on. Thanks... Can this made to work for the images within blocks also.. ie "Best Sellers" block..?

Elkhorn Graphics LLC
Cs-Cart 4.7.1  SP3


 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1416 posts

Posted 06 June 2015 - 07:38 PM #8

What a awesome add-on. Thanks... Can this made to work for the images within blocks also.. ie "Best Sellers" block..?


Hi there CarStickersDecals

this is already working in there too. Actually it works for all kinds of products images nomatter where you have them.

Fotis
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 

Posted 06 June 2015 - 07:41 PM #9

Hi there CarStickersDecals

this is already working in there too. Actually it works for all kinds of products images nomatter where you have them.

Fotis


Sorry just noticed that.. Had to clear the cache... My bad..

Elkhorn Graphics LLC
Cs-Cart 4.7.1  SP3


 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 903 posts

Posted 07 June 2015 - 08:25 PM #10

i noticed there is minor issue in the error log file like :

/app/addons/auto_alt/func.php on line 15

 

Posted 07 June 2015 - 09:40 PM #11

i noticed there is minor issue in the error log file like :

/app/addons/auto_alt/func.php on line 15


Not showing in our errorlog file.. Been running it for over a day now..
How frequently are you seeing it pop up?

Elkhorn Graphics LLC
Cs-Cart 4.7.1  SP3


 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1416 posts

Posted 07 June 2015 - 09:53 PM #12

i noticed there is minor issue in the error log file like :

/app/addons/auto_alt/func.php on line 15


HI demeldoo

have it over a dozen of sites, no problem or no log entries about it. You must be having some kind of conflict.

Fotis
Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 
  • fleaffair
  • Senior Member
  • Members
  • Join Date: 11-Jun 14
  • 537 posts

Posted 09 June 2015 - 02:54 AM #13

Hi dvsgr,

Thanks for this awesome addon , just a small issue I found if a thumbnail of a product has additional images this addon doesnt add ALT tag as Title for them. Could you please let me know how we can get it done ?

Thanks again.
Warm Regards,
Admin | MVE: 4.2.4

 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 903 posts

Posted 14 June 2015 - 01:05 PM #14

HI demeldoo

have it over a dozen of sites, no problem or no log entries about it. You must be having some kind of conflict.

Fotis


also on 4.3.1??? i have to check... again... only differnce is lazy loader enabled on my store...hmm...

 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 903 posts

Posted 14 June 2015 - 01:36 PM #15

cloudfront?

 

Posted 14 June 2015 - 07:40 PM #16

also on 4.3.1??? i have to check... again... only differnce is lazy loader enabled on my store...hmm...

We're using lazyloader and still works..

cloudfront?

May be your issue..

Elkhorn Graphics LLC
Cs-Cart 4.7.1  SP3


 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 903 posts

Posted 16 June 2015 - 07:52 PM #17

We're using lazyloader and still works..

May be your issue..


hello,

yes it works... but only logs some notices in the log file...only mentioned this info .

 
  • IsItFast
  • Senior Member
  • Members
  • Join Date: 16-Sep 08
  • 471 posts

Posted 26 June 2015 - 04:00 AM #18

Awesome! Had this on my v2.1.4 store. Needed it on my 4.3.1 store and here it is. While it seems to work for thumbnails, it doesn't seem to give the alt text for full size images. Or at least from what I can tell...am I missing something?

V4.3.1 with about 10,000 highly customizable products. Several mods done....some of which now come standard with CS now. (Started with V1.3.5)

V3.0 in a few other small stores.


 
  • krola
  • Advanced Member
  • Members
  • Join Date: 18-Jun 11
  • 68 posts

Posted 20 November 2015 - 12:52 PM #19

this is great!

Thanks to all whom are resposible!



 
  • ffwd
  • Junior Member
  • Members
  • Join Date: 22-Aug 09
  • 22 posts

Posted 26 February 2016 - 03:30 PM #20

I tried this on 4.3.2 and does not seems to work, i cleared the cache too.

 

Anyone is using 4.3.2 or higher, who could report if it is working for you.