dream0614 2014-10-03 06:32
浏览 35
已采纳

在Symfony 2中路由到图像

I try to use Bootstrap Thumbnail Gallery with Symfony 2, in template I write something like this:

<div class="col-lg-3 col-md-4 col-xs-6 thumb">
      <a class="thumbnail" href='<img src="{{ asset("uploads/car_photos/" ~ carPhotos.path) }}" alt=""/>'>
           <img src="{{ asset('uploads/car_photos/' ~ carPhotos.path) }}" width="200" height="100" alt=""/>
      </a>
 </div>

In my browser, I get two equals pathes:

<img src="/uploads/car_photos/b5d8d11dae317ad488f0d2f88fc9b42ec40de103.jpeg" alt=""/>

But when I click on the image, I get the next error:

No route found for "GET /user/car/show/%3Cimg%20src=%22/uploads/car_photos/b5d8d11dae317ad488f0d2f88fc9b42ec40de103.jpeg%22%20alt=%22%22/%3E" (from "http://ontheway/app_dev.php/user/car/show/1")

Please help me, I am new in Symfony 2 and dont know all features.

  • 写回答

1条回答 默认 最新

  • duanfen7676 2014-10-03 06:37
    关注

    You put an image tag in the href of your anchor tag, you cannot do that.

    Try this:

    <div class="col-lg-3 col-md-4 col-xs-6 thumb">
          <a class="thumbnail" href='{{ asset("uploads/car_photos/" ~ carPhotos.path) }}'>
               <img src="{{ asset('uploads/car_photos/' ~ carPhotos.path) }}" width="200" height="100" alt=""/>
          </a>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度