Jump to content

(SOLVED) Alt Text category Images


Recommended Posts

PrestaShop already uses the category name in the alt and title tags. Were you wanting something different? You can change line 24 (in PrestaShop v1.3.2) of category.tpl in your theme's directory:

<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />

Link to comment
Share on other sites

Hi rocky, thanks thats right but I can't figure out why my alt is always empty on every images when I check with firebug it just shows alt ""

for the title its working fine, but the alt doesnt show up... The codes for title and alt are the same.


getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" />
Link to comment
Share on other sites

Looks like it's an issue with the Moon theme you are using. It has been modified to remove the alt and title tags. You need to edit themes/moon/category.tpl:

<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
   {if $subcategory.id_image}
       <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'subcategory')}" alt="" />
   {else}
       <img src="{$img_cat_dir}default-subcategory.jpg" alt="" />
   {/if}



Change it to the following to display the category name in the alt tag:

<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
   {if $subcategory.id_image}
       <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'subcategory')}" alt="{$category->name|escape:'htmlall':'UTF-8'}"  />
   {else}
       <img src="{$img_cat_dir}default-subcategory.jpg" alt="{$category->name|escape:'htmlall':'UTF-8'}"  />
   {/if}



or the following to display the category description in the alt tag:

<a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
   {if $subcategory.id_image}
       <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'subcategory')}" alt="{$category->description|escape:'htmlall':'UTF-8'}"  />
   {else}
       <img src="{$img_cat_dir}default-subcategory.jpg" alt="{$category->description|escape:'htmlall':'UTF-8'}"  />
   {/if}

Link to comment
Share on other sites

Hi Rocky, I tried to change it for that code

getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">
                   {if $subcategory.id_image}
getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'subcategory')}" alt="{$subcategory->name|escape:'htmlall':'UTF-8'}"  />
   {                else}
name|escape:'htmlall':'UTF-8'}"  />
                   {/if}



But the tag becomes empty again... i tried to delete all the smarty compiles file and still empty. After I reput the old code with the category than it shows the category name like before. I guess its very simple but this did not work in changing the alt text for subcategory. It just made it empty again.

Any idea ?

Thanks

Link to comment
Share on other sites

  • 1 month later...

Hello,

I've read your post with lot of interest.
I am facing quite a similar problem with the Title tag.

Ex:

I have a product named : "PrOduct"
I change the name to "Product"
but i can see that in the category page (which call product-list.tpl), on mouse over , titles remains "PrOduct"
except only in the product page where the main picture title changed to "Product" but the thumb picture is still "PrOduct"

I tried to delete the smarty cache, regenerating url-rewriting...
can't find a way to make it working

Here is the code of my category-list.tpl



{$product.name|truncate:30|escape:'htmlall':'UTF-8'}


Ref: {$product.reference|strip_tags:'UTF-8'|truncate:360}



hope you can help.

Regards.

Nicolas

Link to comment
Share on other sites

The $product.name comes from the ps_product_lang table and the $product.legend comes from the ps_image_lang table. Check to make sure the corresponding row for the product ID doesn't have "PrOduct" anywhere. If it doesn't, it must be a cache issue.

Link to comment
Share on other sites

  • 4 months later...
Oops, change $category to $subcategory


Thank you, that worked for me as well. It did drive me crazy that the alt showed only category name, not description.

Firefox is not showing the alt text, so I added also title atribute:


Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...