Paw*_*dej 2 assets image symfony twig
当我将图像存储在我的包中时,dir结构显示图像很容易使用Assetic从文档中获取:
{% image '@AcmeFooBundle/Resources/public/images/example.jpg'
filter='jpegoptim' output='/images/example.jpg'
%}
<img src="{{ asset_url }}" alt="Example"/>
{% endimage %}
Run Code Online (Sandbox Code Playgroud)
但是如何为我上传的图片使用资产?在我的getWebPath下面返回相对于web dir的路径,例如:"/ uploads/images/images.jpg".也许这个解决方案没问题,没有必要使用资产?我认为将它用于像jpegoptim这样的过滤可能很有用
<img src="{{app.request.basepath}}/{{ entity.getWebPath }}">
Run Code Online (Sandbox Code Playgroud)
<img src="{{ app.request.scheme ~ '://' ~ app.request.host ~ '/' ~ entity.getWebPath }}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8628 次 |
最近记录: |