how do smarty check file_exists ?
My version does not find the picture:

 {foreach from=$item.item_img key=id item=i} {if file_exists("{$host}/item_images/$i")} <div class="item-small-image{if $id==0} selected{/if}" style="background-image: url({$host}/item_images/{$i});" data-name="{$i}"> </div> {else} <div class="item-small-no-image"> <img src="{$host}/images/no_image.jpg"/> </div> {/if} {/foreach} 
  • such things are not usually made in the template. In general, this is possible, of course. judging by the code (bg-image url), your $host contains the path relative to the site root, and the absolute path in the file system is required for file_exists . - teran
  • @teran, respectively, the author simply needs to change $ host in file_exists , where the path is relative to the site to some $ path, where the path is relative to the image directory in the file system, so that it is: /var/www/site.ru/images/ - lampa
  • @lampa author needs to transfer the image search code to the controller / pkhp-logic, and not clutter up the template with intrinsic tasks - teran
  • @teran is understandable, but the author asks for something else. - lampa

0