If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Categories, Products, Attributes / Alt text in attributes images

Alt text in attributes images

Started by nick1973 on 7 Dec 2021, 11:01 AM · Views: 2,045

Results 1 to 9 of 9
7 Dec 2021, 11:01 AM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Alt text in attributes images

Does anybody know how I can get alt text into my attributes images please?

Currently they output like this:

<img src="images/attributes/single-block.png" alt="" width="270" height="41">

As you can see the alt text is missing.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Dec 2021, 4:07 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Alt text in attributes images

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Dec 2021, 4:15 PM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Alt text in attributes images

swguy:

Admin > Configuration > Product Info - Show Option Values Name Below Attributes Image
https://docs.zen-cart.com/user/admin_pages/configuration/configuration_productinfo/#product_info__show_option_values_name_below_attributes_image

That is already set to '1'

It doesn't apply it to the ALT TAG

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Dec 2021, 8:09 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Alt text in attributes images

Ah you're right. OK. Take includes/modules/attributes.php and copy to includes/modules/YOUR_TEMPLATE/attributes.php.
Then go through that file. Everywhere you see the config flag I mentioned PRODUCT_IMAGES_ATTRIBUTES_NAMES
right before that you will see a call to zen_image. It's in 6 places.

Change those zen_image calls so that the second parameter to zen_image is $products_options->fields['products_options_values_name']
(this is the value which is shown when PRODUCT_IMAGES_ATTRIBUTES_NAMES = 1).

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Dec 2021, 8:44 PM
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Alt text in attributes images

swguy:

Ah you're right. OK. Take includes/modules/attributes.php and copy to includes/modules/YOUR_TEMPLATE/attributes.php.
Then go through that file. Everywhere you see the config flag I mentioned PRODUCT_IMAGES_ATTRIBUTES_NAMES
right before that you will see a call to zen_image. It's in 6 places.

Change those zen_image calls so that the second parameter to zen_image is $products_options->fields['products_options_values_name']
(this is the value which is shown when PRODUCT_IMAGES_ATTRIBUTES_NAMES = 1).

Sorry if I am misunderstanding here. ```php
$products_options->fields['products_options_values_name']


```php
if (!empty($products_options->fields['attributes_image'])) {                        $tmp_attributes_image .= '<div class="custom-control custom-checkbox attribImg">' . zen_draw_checkbox_field('id[' . $products_options_id . ']['.$products_options_value_id.']', $products_options_value_id, $selected_attribute, 'id="' . $inputFieldId . '" ' . $data_properties . $field_disabled) . '<br>' . zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image']) . '<label class="custom-control-label attribsCheckbox" for="' . $inputFieldId . '">' . (PRODUCT_IMAGES_ATTRIBUTES_NAMES == '1' ? '<br>' . $products_options->fields['products_options_values_name'] : '') . (!empty($products_options_details_noname) ? '<br>' . $products_options_details_noname : '') . '</label></div>' . "\n";                    } else {                        $tmp_attributes_image .= '<div class="custom-control custom-checkbox attribImg">' . zen_draw_checkbox_field('id[' . $products_options_id . ']['.$products_options_value_id.']', $products_options_value_id, $selected_attribute, 'id="' . $inputFieldId . '" ' . $data_properties . $field_disabled) . '<br />' . '<label class="custom-control-label attribsCheckbox" for="' . $inputFieldId . '">' . $products_options->fields['products_options_values_name'] . (!empty($products_options_details_noname) ? '<br>' . $products_options_details_noname : '') . '</label></div>' . "\n";                    }                    break;

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Dec 2021, 9:19 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Alt text in attributes images

Change

zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image'])

to

zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image'], $products_options->fields['products_options_values_name'])

in each place it's next to the check of PRODUCT_IMAGES_ATTRIBUTES_NAMES (because that's where the attributes image is shown).

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Dec 2021, 9:43 PM
#7
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Alt text in attributes images

swguy:

Change

zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image'])

to

zen_image(DIR_WS_IMAGES . $products_options->fields['attributes_image'], $products_options->fields['products_options_values_name'])

in each place it's next to the check of PRODUCT_IMAGES_ATTRIBUTES_NAMES (because that's where the attributes image is shown).

Brilliant, thank you!

I thought that was what you meant but wasn't sure which is why I came back to you.

That worked. Now I don't have missing ALT TAGS on my product pages :-)

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

7 Dec 2021, 9:49 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Alt text in attributes images

If you know how to submit a PR, this would be a good fix to add to 1.5.8.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Dec 2021, 9:57 PM
#9
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Alt text in attributes images

swguy:

If you know how to submit a PR, this would be a good fix to add to 1.5.8.

Even better if the attributes images could also have an alt text box in the admin when images are uploaded to attributes. This could be useful for SEO purposes as they could then contain keywords that are relative to the product. Obviously without Keyword Stuffing.

Where would I do that then?

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk