<tal:def define="
  alignment    options/alignment_selector | nothing;
  capsulestyle options/capsule_style | nothing;
  capsuleclass python: capsulestyle and ' ' + capsulestyle or '';
  capsuletitle options/capsule_title | nothing;
  imagepath    options/image_path;
  image        python: context.restrictedTraverse(str(imagepath));
  dimensions   python: image.getCanonicalWebScale();
  imagewidth   python: dimensions[0];
  imagelink    options/image_link | nothing;
  linkurl      options/link_url | nothing;
  reference    python: imagelink and (imagelink == 'hires' and imagepath+'?hires' or linkurl);
  captiontext  options/caption_text | nothing;
  creditprefix options/credit_prefix | nothing;
  creditlink   options/credit_link | nothing;
  credittext   options/credit_text | nothing;
">
<!-- encaptionator -->
<div tal:omit-tag="not:alignment"
  tal:attributes="class alignment">
<div tal:attributes="
  class string:encaptionator${capsuleclass};
  style string:width:${imagewidth}px;
">

<h5 class="heading"
  tal:condition="capsuletitle"
  tal:content="structure capsuletitle">
    Title....
</h5>

<a class="image"
  tal:omit-tag="not:reference"
  tal:attributes="
    href reference;
    title options/link_tooltip | nothing;
">
<img tal:replace="structure image/tag" />
</a>

<p class="p" 
  tal:condition="captiontext"
  tal:content="structure captiontext">
    Caption text....
</p>

<p class="credit"
  tal:condition="python: creditprefix or credittext">
<span tal:replace="structure creditprefix">
  Photographer:
</span>
<a tal:omit-tag="not:creditlink"
  tal:attributes="
    href creditlink;
    title options/creditlink_tooltip | nothing;
">
<span tal:replace="structure credittext">
  Credit text....
</span>
</a>
</p>

</div>
</div>
<!-- /encaptionator -->
</tal:def>