Skip to main content

No width and height attributes in Product list.

More
2 years 9 months ago #357985 by KEKO512
-- 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.

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

More
2 years 9 months ago #357989 by nicolas
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:
Code:
$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:
Code:
$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.

More
2 years 9 months ago #357992 by KEKO512
Thanks a lot, this was solved.

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

Time to create page: 0.141 seconds
Powered by Kunena Forum