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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?