Symfony2 - checking if file exists

前端 未结 6 1239
执笔经年
执笔经年 2020-12-05 05:59

I have a loop in Twig template, which returns multiple values. Most important - an ID of my entry. When I didn\'t use any framework nor template engine, I used simply

6条回答
  •  一向
    一向 (楼主)
    2020-12-05 06:15

    I've had the same problem as Tomek. I've used Sybio's solution and made the following changes:

    1. app/config.yml => add "/" at the end of web_path

      parameters:
          web_path: %kernel.root_dir%/../web/
      
    2. Call file_exists without "asset" :

      {% if file_exists(web_path ~ 'img/games/'~item.getGame.id~'.jpg') %}
      

    Hope this helps.

提交回复
热议问题