No width and height attributes in Product list.

  • Posts: 5
  • Thank you received: 0
11 months 3 weeks ago #357985

-- HikaShop version -- : 5.0.2
-- Joomla version -- : 5.0.1
-- PHP version -- : 8.2
-- Browser(s) name and version -- : Firefox 120.0.1

When evaluating my website on Google PageSpeed Insights.

In product list , I receive the following message.

"Image elements don't have any explicit width or height attributes"

This affects Google's evaluation.

There is some way to fix it.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 months 3 weeks ago #357989

Hi,

First, please note that this is not as clear cut as this.
I invite you to read here:
stackoverflow.com/questions/32217863/seo...r-responsive-website
Specifying the height and width of the images can impact the responsiveness of the pages, which in turn will degrade SEO performances.

To add the width and height attributes to product images on listings, you can edit the view file product / listing_img_title.php via the menu Display>Views and change the line:

$html = '<img class="hikashop_product_listing_image" title="'.$this->escape((string)@$this->row->file_description).'" alt="'.$this->escape((string)@$this->row->file_name).'" src="'.$img->url.'"/>';
to:
$html = '<img class="hikashop_product_listing_image" title="'.$this->escape((string)@$this->row->file_description).'" alt="'.$this->escape((string)@$this->row->file_name).'" src="'.$img->url.'" width="'.$img->width.'" height="'.$img->height.'"/>';

The following user(s) said Thank You: KEKO512

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 months 3 weeks ago #357992

Thanks a lot, this was solved.

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum