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
```<br />
#content<br />
```php
<br />
<?php<br />
if ( !defined('BOOTSTRAP') ) { die('Access denied'); }<br />
fn_register_hooks(<br />
'get_product_data_post',<br />
'gather_additional_products_data_post'<br />
);<br />
```<br />
<br />
2.<br />
#file```php
app/addons/my_changes/func.php
```<br />
#content<br />
```php
<br />
<?php<br />
<br />
if ( !defined('BOOTSTRAP') ) { die('Access denied'); }<br />
use Tygh\Registry;<br />
function fn_my_changes_get_product_data_post(&$product_data, $auth, $preview, $lang_code){<br />
if(AREA=='C'){<br />
if(!empty($product_data['main_pair'])){<br />
if(empty($product_data['main_pair']['detailed']['alt'])){<br />
$product_data['main_pair']['detailed']['alt'] = $product_data['product'];<br />
}<br />
}<br />
if(!empty($product_data['image_pairs'])){<br />
foreach ($product_data['image_pairs'] as $key => $value) {<br />
if(empty($value['detailed']['alt'])){<br />
$product_data['image_pairs'][$key]['detailed']['alt'] = $product_data['product'];<br />
}<br />
}<br />
}<br />
}<br />
}<br />
function fn_my_changes_gather_additional_products_data_post($product_ids, $params, &$products, $auth){<br />
if(AREA=='C'){<br />
foreach ($products as $key => $product_data) {<br />
if(!empty($product_data['main_pair'])){<br />
if(empty($product_data['main_pair']['detailed']['alt'])){<br />
$products[$key]['main_pair']['detailed']['alt'] = $product_data['product'];<br />
}<br />
}<br />
if(!empty($product_data['image_pairs'])){<br />
foreach ($product_data['image_pairs'] as $k => $value) {<br />
if(empty($value['detailed']['alt'])){<br />
$products[$key]['image_pairs'][$k]['detailed']['alt'] = $product_data['product'];<br />
}<br />
}<br />
}<br />
}<br />
}<br />
}<br />
```<br />
<br />
You can test it here:<br />
[indent=1][b]Category[/b]: [url="http://www.hungryweb.net/demo/sports-and-outdoors/golf/golf-bags-and-carts/"]http://www.hungryweb.net/demo/sports-and-outdoors/golf/golf-bags-and-carts/ [/url][/indent]<br />
[indent=1][b]Product Details:[/b] [url="http://www.hungryweb.net/demo/sports-and-outdoors/golf/golf-bags-and-carts/cg-lightweight-cart-bag.html"]http://www.hungryweb...t-cart-bag.html[/url][/indent]<br />
<br />
I hope that helps,<br />
<br />
---<br />
Valentin<br />
[color=#808080][size=2]part of hungryweb.net[/size][/color]
dvsgr
September 15, 2014, 12:00am
2
Super Valentin,
and with your permission, here is the package as Addon for those who don't want to get there hands dirty!
[attachment=8421:auto_alt.zip]
auto_alt.zip
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
dvsgr
September 16, 2014, 12:00am
4
You are right ecomLabs to mention this.
I forgot to mention that, as I have corrected in the addon package.
Fotis
[quote name=‘eComLabs’ timestamp=‘1410870966’ post=‘192316’]
Dear Vali,
<br />
app/addons/my_changes/ini.php<br />
```<br />
<br />
Please correct your message and change the file name to [b]init.php[/b]. It can confuse CS-Cart users who is not familiar with the add-ons<br />
[/quote]<br />
Done, thank you <img src="upload://ssa1U17ndImgNZSdwFNmOF2yUgM.png" class="bbc_emoticon" alt=";)">
helloo… it seems that this addon is working on 4.3.1
What a awesome add-on. Thanks… Can this made to work for the images within blocks also… ie “Best Sellers” block…?
dvsgr
June 6, 2015, 12:00am
8
[quote name='CarStickersDecals' timestamp='1433614702' post='217631']
What a awesome add-on. Thanks… Can this made to work for the images within blocks also… ie “Best Sellers” block…?
[/quote]
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
[quote name='dvsgr' timestamp='1433619514' post='217640']
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
[/quote]
Sorry just noticed that… Had to clear the cache… My bad…
i noticed there is minor issue in the error log file like :
/app/addons/auto_alt/func.php on line 15
[quote name='demeldoo' timestamp='1433708739' post='217696']
i noticed there is minor issue in the error log file like :
/app/addons/auto_alt/func.php on line 15
[/quote]
Not showing in our errorlog file… Been running it for over a day now…
How frequently are you seeing it pop up?
dvsgr
June 7, 2015, 12:00am
12
[quote name='demeldoo' timestamp='1433708739' post='217696']
i noticed there is minor issue in the error log file like :
/app/addons/auto_alt/func.php on line 15
[/quote]
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
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.
[quote name='dvsgr' timestamp='1433714036' post='217700']
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
[/quote]
also on 4.3.1??? i have to check… again… only differnce is lazy loader enabled on my store…hmm…
[quote name='demeldoo' timestamp='1434287117' post='218674']
also on 4.3.1??? i have to check… again… only differnce is lazy loader enabled on my store…hmm…
[/quote]
We're using lazyloader and still works…
[quote name='demeldoo' timestamp='1434289014' post='218678']
cloudfront?
[/quote]
May be your issue…
[quote name='CarStickersDecals' timestamp='1434310829' post='218703']
We're using lazyloader and still works…
May be your issue…
[/quote]
hello,
yes it works… but only logs some notices in the log file…only mentioned this info .
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?
krola
November 20, 2015, 12:00am
19
this is great!
Thanks to all whom are resposible!
ffwd
February 26, 2016, 12:00am
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.