2013-06-28 92 views
2

屬性與Image FieldPlone敏捷圖像內容缺少getImage方法?在<strong>敏捷內容</strong>類型可用

>>> app.Plone.test.image. 
app.Plone.test.image.__class__(  app.Plone.test.image.__provides__(  app.Plone.test.image._height   app.Plone.test.image._p_state 
app.Plone.test.image.__delattr__(  app.Plone.test.image.__reduce__(  app.Plone.test.image._p_activate(  app.Plone.test.image._setData(
app.Plone.test.image.__dict__   app.Plone.test.image.__reduce_ex__( app.Plone.test.image._p_changed   app.Plone.test.image._width 
app.Plone.test.image.__doc__   app.Plone.test.image.__repr__(   app.Plone.test.image._p_deactivate( app.Plone.test.image.contentType 
app.Plone.test.image.__format__(  app.Plone.test.image.__setattr__(  app.Plone.test.image._p_delattr(  app.Plone.test.image.data 
app.Plone.test.image.__getattribute__( app.Plone.test.image.__setstate__(  app.Plone.test.image._p_estimated_size app.Plone.test.image.filename 
app.Plone.test.image.__getstate__(  app.Plone.test.image.__sizeof__(  app.Plone.test.image._p_getattr(  app.Plone.test.image.getFirstBytes(
app.Plone.test.image.__hash__(   app.Plone.test.image.__str__(   app.Plone.test.image._p_invalidate( app.Plone.test.image.getImageSize(
app.Plone.test.image.__implemented__( app.Plone.test.image.__subclasshook__( app.Plone.test.image._p_jar    app.Plone.test.image.getSize(
app.Plone.test.image.__init__(   app.Plone.test.image.__weakref__  app.Plone.test.image._p_mtime   app.Plone.test.image.open(
app.Plone.test.image.__module__   app.Plone.test.image._blob    app.Plone.test.image._p_oid    app.Plone.test.image.openDetached(
app.Plone.test.image.__new__(   app.Plone.test.image._data    app.Plone.test.image._p_serial   app.Plone.test.image.size 
app.Plone.test.image.__providedBy__( app.Plone.test.image._getData(   app.Plone.test.image._p_setattr(

我期望的方法getImagegetImageURL方法存在......以至於我發現自己通過以下圍繞其沒有工作:

def get_image(self): 
    return "data:%s;base64,%s" % (self.context.image.contentType, 
     base64.encodestring(self.context.image.data)) 

和:

<img tal:attributes="src view/get_image" /> 

哪些工作,但在許多(希望顯而易見的)方式不理想。現在,這種類型的默認視圖通過構件資源提供所需的功能:

view/++widget++form.widgets.image/@@download/the-image.png 

但是,因爲我已經定製的這個默認視圖我沒有訪問它(AFAICT)類型。應該有getImage方法嗎?或者我錯過了其他一些明顯的方法。

回答

3

你有沒有試過在plone.app.imagescales路

<img tal:replace="structure context/@@images/shortnameofmyfield/thumb" /> 
+0

這很有效,謝謝! (我沒有看到@@圖像備忘錄。) – aclark

1

我解決了類似的問題是這樣的:

selected_image.restrictedTraverse("@@images").scale('image', width=None, height=None).index_html() 

這將返回其原始尺寸的圖像。

相關問題