Dav*_*ima 5 plone image widget dexterity
我正在为我的视图类使用DisplayForm并成功渲染NamedBlobImage字段:
<span tal:replace="structure view/w/image/render" />
Run Code Online (Sandbox Code Playgroud)
如何调整ZPT以显示不同的图像大小,如'image_mini'或plone.app.imaging中的任何其他图像?
与Archetypes图像字段一样,Dexterity中会自动提供一组预定义的比例.获得这些的便捷快捷方式是使用如下代码:
<img src=”#” tal:replace=”structure? context/@@images/fieldname/scale” />
Run Code Online (Sandbox Code Playgroud)
其中"fieldname"是字段的名称,"scale"是预定义的标度之一.
有关完整信息,请查看http://pypi.python.org/pypi/plone.namedfile/#image-scales.
你应该使用plone.app.imaging.
这将是:
<img tal:define="scales context/@@images;
thumbnail python: scales.scale('image', width=64, height=64);"
tal:condition="thumbnail"
tal:attributes="src thumbnail/url;
width thumbnail/width;
height thumbnail/height" />
Run Code Online (Sandbox Code Playgroud)
上下文是保存图像和图像的对象(在scales.scale('image'...)上是包含要调整大小的图像的字段名称.
如果您想使用预定义的图像大小,只需使用:
<img tal:define="scale context/@@images"
tal:replace="structure python: scale.scale('image',
scale='mini').tag()" />
Run Code Online (Sandbox Code Playgroud)
干杯
| 归档时间: |
|
| 查看次数: |
837 次 |
| 最近记录: |