News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

add Image Alt-Text to all products

Started by modernmagic, April 06, 2022, 08:24:28 AM

Previous topic - Next topic

modernmagic

My site has 900 products they all need "Image Alt-Text". 

Is there a way to generate the Image Alt-Text from the "file title"(and remove the file extension if possible) from all 900 products at once? 

pinochico

#1
yes, of course

Find place, where is generate image in PHP and add as params.
We add this hack into VM all time, we don't wait for DEV team :)

But.

You have to go to this file:
administrator/components/com_virtuemart/helpers/mediahandler.php

Find this code:

Quote
if(empty($this->file_meta)){
         if(!empty($this->file_description)){
            $file_alt = $this->file_description;
         } else if(!empty($this->file_name)) {
            $file_alt = $this->file_name;
         } else {
            $file_alt = '';
         }
      } else {
         $file_alt = $this->file_meta;
      }

and change for you.

And in function displayIt you can change too - add width, height or aspect-ratio for eliminate CLS.

We use this:

Quote$image = '<img src="' . $image_href . '" alt="' . $file_alt . '" title="' . $file_alt . '" ' . $imageArgs . ' width="' . $size[0] . '" height="' . $size[1] . '" style="aspect-ratio: ' . $size[0] . ' / ' . $size[1] . '"/>';
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products