gerry293 Posted October 29, 2010 Share Posted October 29, 2010 Hi all,For SEO purpose I would like to know if it is possible to add ALT and title text for the images of categories and subcategories.Thanks all Link to comment Share on other sites More sharing options...
rocky Posted October 29, 2010 Share Posted October 29, 2010 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 More sharing options...
gerry293 Posted October 29, 2010 Author Share Posted October 29, 2010 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 More sharing options...
rocky Posted October 29, 2010 Share Posted October 29, 2010 Can you provide a link to your site so I can investigate? Link to comment Share on other sites More sharing options...
gerry293 Posted October 29, 2010 Author Share Posted October 29, 2010 sure, thanks Link to comment Share on other sites More sharing options...
rocky Posted October 30, 2010 Share Posted October 30, 2010 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 More sharing options...
gerry293 Posted October 30, 2010 Author Share Posted October 30, 2010 Hi Rocky, unfortunately that little change didnt work.The code seems to be taken from the smarty compile files thats in .php.I check the code in the compile file and its like this:_tpl_vars['link']->getCategoryLink($this->_tpl_vars['subcategory']['id_category'],$this->_tpl_vars['subcategory']['link_rewrite']))) ? $this->_run_mod_handler('escape', true, $_tmp, 'htmlall', 'UTF-8') : smarty_modifier_escape($_tmp, 'htmlall', 'UTF-8')); ?>" title="<?php echo ((is_array($_tmp=$this->_tpl_vars['subcategory']['name'])) ? $this->_run_mod_handler('escape', true, $_tmp, 'htmlall', 'UTF-8') : smarty_modifier_escape($_tmp, 'htmlall', 'UTF-8')); ?>"> <?php if ($this->_tpl_vars['subcategory']['id_image']): ?>_tpl_vars['link']->getCatImageLink($this->_tpl_vars['subcategory']['link_rewrite'],$this->_tpl_vars['subcategory']['id_image'],'subcategory'); ?>" alt="" /> <?php else: ?>_tpl_vars['img_cat_dir']; ?>default-subcategory.jpg" alt="" /> <?php endif; ?>so seeing the alt is empty, i tried to insert the same code inside the alt like in the tpl file, but than when i check if it worked, the alt text is just the code and doesnt take the category title into consideration.Thanks if you have any clue. Link to comment Share on other sites More sharing options...
rocky Posted October 31, 2010 Share Posted October 31, 2010 Looks like a cache issue. Try deleting all the files except index.php in the tools/smarty/compile directory. Link to comment Share on other sites More sharing options...
gerry293 Posted October 31, 2010 Author Share Posted October 31, 2010 Ok thanks, I did that, now the alt text shows up, but the text is showing the category where the image appears and not the subcategory that the images refers to.Anyway to modify that code ?Thanks for your help Link to comment Share on other sites More sharing options...
rocky Posted November 1, 2010 Share Posted November 1, 2010 Oops, change $category to $subcategory Link to comment Share on other sites More sharing options...
gerry293 Posted November 1, 2010 Author Share Posted November 1, 2010 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 More sharing options...
rocky Posted November 1, 2010 Share Posted November 1, 2010 I think it should be subcategory.name not subcategory->name. Link to comment Share on other sites More sharing options...
gerry293 Posted November 1, 2010 Author Share Posted November 1, 2010 Great your the best once again!Thank you so much for your time. Link to comment Share on other sites More sharing options...
ncandelier Posted December 3, 2010 Share Posted December 3, 2010 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 workingHere 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 More sharing options...
rocky Posted December 4, 2010 Share Posted December 4, 2010 You seem to be using an older version of the theme that had the image legend on hover instead of the product name. You must go to the "2. Images" tab of the product editor and change the name there. Link to comment Share on other sites More sharing options...
ncandelier Posted December 4, 2010 Share Posted December 4, 2010 Thank you for your answer.Yes i am using theme Black And White with Presta 1.3I have check mode compatibility with older themI also changed the name of the Image, but it remains "PrOduct" in Title Tag.. very strange.Is the Title parked somewhere in Database ? Link to comment Share on other sites More sharing options...
rocky Posted December 4, 2010 Share Posted December 4, 2010 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 More sharing options...
ncandelier Posted December 4, 2010 Share Posted December 4, 2010 Hello RockyYes i can find "PrOduct" in the row legend of the Table...It means that i have 200 product to change manually in MySQL ...I think i will drop the use and display of the Title Tag.Thank you for your clarification Link to comment Share on other sites More sharing options...
bomo Posted April 25, 2011 Share Posted April 25, 2011 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 More sharing options...
richnicol Posted February 5, 2014 Share Posted February 5, 2014 Hi Rocky, I am working on a site: http://www.rockandstoneyork.co.uk/52-paving I am wanting to change the Image Alt Text as i dont want them to be all the same as the product title. How do i do this? I have never had a client who uses this format before so i am new to Presta. Thanks for your help Rich Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now