hakeryk2 Posted February 13, 2016 Share Posted February 13, 2016 (edited) Hello, I have kinda weird problem with Prestahop 1.6.1.4 which is not modified or whatever. When I am trying to add a thumbnail for a category or subcategory it is uploading but it is not showing in front office. This is how I added the photo (ofcourse with save button) and after this it is still not showing it (even after ctrl+f5) Funny thing is that this file is uploaded on ftp into /img/c/.. folder. Can anyone help me? Edited February 13, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted February 13, 2016 Share Posted February 13, 2016 Is the theme using the proper image size? Check that the size (could be medium_default as well as category_default) is active for categories, then regenerate thumbnails Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 13, 2016 Author Share Posted February 13, 2016 (edited) I am using default theme for Prestahop so it should be ok. Those are settings for my thumbnails and I tried to regenerate categories thumbnails with these settings. I also tried with selecting "No" for "Erase previous images". and it is still not showing up. Edited February 13, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted February 15, 2016 Share Posted February 15, 2016 Check that they are set to use medium_default in the template (you can right click and inspect the elements, or in any case check category.tpl Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 15, 2016 Author Share Posted February 15, 2016 (edited) This is what I am getting with inspection: I don't know why there is no "img" in link (after domain name and befe /c/) but even if I will change it: domain.pl/c/pl-default-medium_default/18.jpg it is not working (because there is no such file on the server. But when I change the link in inspection to domain.pl/img/c/18-medium_default.jpg it is showing the thumbnail because it is correct path to this image (see FTP dump below) Is it only for me not working? Conclusion: curently URL is http://domain.pl/c/pl-default-medium_default/18.jpg and it supose to be: domain.pl/img/c/18-medium_default.jpg and this is the code from category.tpl which I think is responsible for that - how should I change it to achieve what I want? <div id="subcategories"> <p class="subcategory-heading">{l s='Subcategories'}</p> <ul class="clearfix"> {foreach from=$subcategories item=subcategory} <li> <div class="subcategory-image"> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}" title="{$subcategory.name|escape:'html':'UTF-8'}" class="img"> {if $subcategory.id_image} <img class="replace-2x" src="{$link->getCatImageLink($subcategory.id_category, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {else} <img class="replace-2x" src="{$img_cat_dir}{$lang_iso}-default-medium_default.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /> {/if} </a> </div> <h5><a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:25:'...'|escape:'html':'UTF-8'}</a></h5> {if $subcategory.description} <div class="cat_desc">{$subcategory.description}</div> {/if} </li> {/foreach} </ul> </div> Edited February 18, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 18, 2016 Author Share Posted February 18, 2016 Sorry for bump but I still cannot solve this issue Link to comment Share on other sites More sharing options...
NemoPS Posted February 19, 2016 Share Posted February 19, 2016 The sad point is that the url is almost correct. It should have a name too, thoughhttp://127.0.0.1:8080/presta1614/c/4-medium_default/tops.jpgUsing any rewriting module? Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 19, 2016 Author Share Posted February 19, 2016 (edited) Im just using default PrestaShop settings in SEO & URL options: Maybe my hosting is the issue: those are settings for PHP, these are correct? P.S I tried with to change Disable Apache's MultiViews option and Disable Apache's mod_security module values but still with no luck. Edited February 19, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted February 20, 2016 Share Posted February 20, 2016 See if it works without friendly urls. It's weird that the image has an id, but not the name, unless the category is named "18" Link to comment Share on other sites More sharing options...
yaniv14 Posted February 20, 2016 Share Posted February 20, 2016 Try to add above: {if $subcategory.id_image} {print_r|@subcategory} Just to see what includes in that variable, because it seems like you are not getting 'id_image'. Also where are the data attribute (data-pin-nopin) is coming from? Are you sure you don't have any override to Category class or controller? Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 20, 2016 Author Share Posted February 20, 2016 (edited) Your code is giving me something like this (I added {/if} as well because You forgot ): I tried to paste it into different places and still no luck because of print_r. Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/**/public_html/themes/default-bootstrap/category.tpl" on line 83 "{print_r|@subcategory}" unknown tag "print_r" <-- thrown in **public_html/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 83 (data-pin-nopin) is my attribute from pinterest chrome extension - it is not related (I checked on different browsers) I tried with BO -> Performance -> Disable all overrides to YES and still no luck. Edited February 20, 2016 by hakeryk2 (see edit history) Link to comment Share on other sites More sharing options...
yaniv14 Posted February 20, 2016 Share Posted February 20, 2016 Oops. {$subcategory|@print_r} you dont need an if statement Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 20, 2016 Author Share Posted February 20, 2016 ----------------------------------------- EDIT: If I change Your code to {if $subcategory.id_image}{$subcategory|@print_r}{/if}and I will paste it after {foreach from=$subcategories item=subcategory} then I am getting something like this: (this copy only from one subcategory) Array ( [id_category] => 18 [id_parent] => 13 [id_shop_default] => 1 [level_depth] => 4 [nleft] => 11 [nright] => 12 [active] => 1 [date_add] => 2015-11-05 16:58:20 [date_upd] => 2016-02-17 22:38:39 [position] => 3 [is_root_category] => 0 [id_lang] => 1 [name] => Sofy i Kanapy [description] => Sofa to właśnie ten cudowny mebel posiadający funkcje, której pozazdrościć mogą mu inne meble - funkcje relaksu! Choć zwana bywa różnie: sofą, kanapą, otomanką tak każdy wie, że jej zadanie jest niezmienne dlatego prezentujemy bardzo wygodne centra dowodzenia pilotem od TV. [link_rewrite] => sofy-i-kanapy [meta_title] => [meta_keywords] => [meta_description] => [id_image] => pl-default [legend] => no picture ) Link to comment Share on other sites More sharing options...
yaniv14 Posted February 20, 2016 Share Posted February 20, 2016 I've just saw your first post and you are uploading category image thumbnail and not cover image. thumbnail image are only displayed in top horizontal menu module. In category page it is looking for category cover image. Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 20, 2016 Author Share Posted February 20, 2016 (edited) I want to have the thumbnail here So I am uploading image to the right place. When I upload category cover image everything is working and cover is showing. So maybe let's try it another way - how should I change this foreach section (it can be hardcoded) to display the image? How should I construct a category id variable in foreach section? What is the code? I will put this directly into url path with this variable and I will try with that. EDIT ---------------------------------------------------------- I found a solution. Not the perfect one but it ok for my purpose. In category.tpl arround 84 line, change that section <img class="replace-2x" src="{$link->getCatImageLink($subcategory.id_category, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /> to this one <img class="replace-2x" src="{$img_cat_dir}{$subcategory.id_category}-medium_default.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" /> And it is working. Not perfectly because it is showing default question mark when thumbnail is not set but it is ok for me. Conclusion: I think that in this whole foreach section something is wrong with {if $subcategory.id_image} statement. Dunno what but I am not professional Prestashop Developer. Thank You guys for Your time. Edited February 20, 2016 by hakeryk2 (see edit history) 1 Link to comment Share on other sites More sharing options...
yaniv14 Posted February 20, 2016 Share Posted February 20, 2016 Hi, Let me explain everything. The category thumb image in not assigned to category.tpl (category page), the only image that being assigned is the main image (category cover image) The assign variables is coming from the front/CategoryController.php The function that retrieve all sub categories from database is getSubCategories that located in classes/Category.php That function does not include thumb image and also have a bug with the cover image. This is the line the assign the 'id_image': $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : Language::getIsoById($id_lang).'-default'; As you can see in this code there is no result for not exists (image not exists), which mean that the 'id_image' variable is always some sort of string and what that mean is that this code in the template: {if $subcategory.id_image}<img class="replace-2x" src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'medium_default')|escape:'html':'UTF-8'}" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" />{else}<img class="replace-2x" src="{$img_cat_dir}{$lang_iso}-default-medium_default.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}" width="{$mediumSize.width}" height="{$mediumSize.height}" />{/if} Doesn't really works the way it should work, anyway it won't solve your issue but just for reference the correct code should be: $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : false; Which return false if no category image found. Now if you want to hard code the category class and add thumb images you can add right under the line I just mentioned something like: $row['id_thumb_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'_thumb.jpg') ? (int)$row['id_category'] : false; Which result in assigning another variable called 'id_thumb_image' and you can show it in the template based on that variable. Something like: {if $subcategory.id_thumb_image} <img class="replace-2x" src="{$img_cat_dir}{$id_thumb_image}_thumb.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}" /> {/if} So..... I haven't tested anything but I think it should works. Hope I didn't miss anything. 1 Link to comment Share on other sites More sharing options...
Vivasan Posted January 15, 2019 Share Posted January 15, 2019 On 2/20/2016 at 9:00 PM, yaniv14 said: Hi, Let me explain everything. The category thumb image in not assigned to category.tpl (category page), the only image that being assigned is the main image (category cover image) The assign variables is coming from the front/CategoryController.php The function that retrieve all sub categories from database is getSubCategories that located in classes/Category.php That function does not include thumb image and also have a bug with the cover image. This is the line the assign the 'id_image': As you can see in this code there is no result for not exists (image not exists), which mean that the 'id_image' variable is always some sort of string and what that mean is that this code in the template: Doesn't really works the way it should work, anyway it won't solve your issue but just for reference the correct code should be: Which return false if no category image found. Now if you want to hard code the category class and add thumb images you can add right under the line I just mentioned something like: Which result in assigning another variable called 'id_thumb_image' and you can show it in the template based on that variable. Something like: {if $subcategory.id_thumb_image} <img class="replace-2x" src="{$img_cat_dir}{$id_thumb_image}_thumb.jpg" alt="{$subcategory.name|escape:'html':'UTF-8'}" /> {/if} So..... I haven't tested anything but I think it should works. Hope I didn't miss anything. I have the same problem, it doesn't work for me, can yoy help me? Link to comment Share on other sites More sharing options...
NemoPS Posted January 16, 2019 Share Posted January 16, 2019 What's your prestashop version? Are you using a custom template? Link to comment Share on other sites More sharing options...
lasseboy Posted February 2, 2020 Share Posted February 2, 2020 HI! i have same problem but my shop is 1.6.1.24 and my theme category.tpl dosent look like yours. what should i changes in my TPL? Here is my category tpl: {* ---------------------------------------- Template Prestashop RosePassion Copyright Prestacrea Author: Prestacrea Website: http://www.prestacrea.com ---------------------------------------- *} {include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./errors.tpl"} {if isset($category)} {if $category->id AND $category->active} <h1> {strip} {$category->name|escape:'htmlall':'UTF-8'} {if isset($categoryNameComplement)} {$categoryNameComplement|escape:'htmlall':'UTF-8'} {/if} <span class="category-product-count"> {include file="$tpl_dir./category-count.tpl"} </span> {/strip} </h1> {if $scenes || $category->description || $category->id_image} <div class="content_scene_cat"> {if $scenes} <!-- Scenes --> {include file="$tpl_dir./scenes.tpl" scenes=$scenes} {else} <!-- Category image --> {if $category->id_image} <div class="cat_img"> <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" /> </div> {/if} {/if} {if $category->description} <div class="cat_desc"> <p>{$category->description}</p> </div> {/if} </div> {/if} {if isset($subcategories)} <!-- Subcategories --> <div id="subcategories"> {assign var='nbItemsPerLine' value=4} <ul class="inline_list"> {foreach from=$subcategories item=subcategory name=subcategory} <li class="{if $smarty.foreach.subcategory.iteration%$nbItemsPerLine == 1}first_item_of_line {/if}span3"> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" title="{$subcategory.name|escape:'htmlall':'UTF-8'}" class="img"> <img src="{$link->getCatImageLink($subcategory.link_rewrite, $subcategory.id_image, 'category')}" alt="{$subcategory.name|escape:'htmlall':'UTF-8'}" /> </a> <a href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'htmlall':'UTF-8'}" class="cat_name" title="{$subcategory.name|escape:'htmlall':'UTF-8'}">{$subcategory.name|truncate:20:'...'|escape:'htmlall':'UTF-8'}</a> {*{if $subcategory.description} <p class="cat_desc">{$subcategory.description|strip_tags:'UTF-8'|truncate:120:'...'|escape:'htmlall':'UTF-8'}</p> {/if}*} </li> {/foreach} </ul> </div> {/if} {if $products} <div class="content_sortPagiBar"> <div class="sortPagiBar"> {include file="$tpl_dir./product-compare.tpl"} {include file="$tpl_dir./nbr-product-page.tpl"} {include file="$tpl_dir./product-sort.tpl"} </div> </div> {include file="$tpl_dir./product-list.tpl" products=$products} <div class="content_sortPagiBar"> <div class="sortPagiBar"> {include file="$tpl_dir./product-compare.tpl"} {include file="$tpl_dir./pagination.tpl"} </div> </div> {/if} {elseif $category->id} <p class="warning">{l s='This category is currently unavailable.'}</p> {/if} {/if} Link to comment Share on other sites More sharing options...
Ray UK Posted June 28, 2021 Share Posted June 28, 2021 (edited) Hi, How can I do this on PS 1.7? Im using the category_default as the category header background and want to use the category thumbnail to display where the category_default was. Thanks UPDATE: It seems to be already included in the 1.7 code. Just put {$category.image.small.url} in where you want it to appear Edited June 28, 2021 by MerseyRay (see edit history) 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