문제

I'm using a DisplayForm for my view class and succeeded rendering a NamedBlobImage field with:

<span tal:replace="structure view/w/image/render" />

How can I tweak that ZPT to display a different image size like 'image_mini' or any other from plone.app.imaging ?

도움이 되었습니까?

해결책

You should use plone.app.imaging for this.

It would be like:

<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" />

Where context is the object which holds the image and image (on scales.scale('image'...) is the field name that has the image you want to resize.

If you want to use the predefined image sizes just use:

<img tal:define="scale context/@@images"
     tal:replace="structure python: scale.scale('image',
                  scale='mini').tag()" />

Cheers

다른 팁

Just as with Archetypes image fields, a set of predefined scales are automatically available in Dexterity. The convenience shortcut to get at these is to use code like:

<img src=”#” tal:replace=”structure
 context/@@images/fieldname/scale” />

where "fieldname" is the name of the field and "scale" is one of the pre-defined scales.

Take a look at http://pypi.python.org/pypi/plone.namedfile/#image-scales for full information.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top