Skip to content

Instantly share code, notes, and snippets.

@meancode
Created August 9, 2010 16:15
Show Gist options
  • Save meancode/515643 to your computer and use it in GitHub Desktop.
Save meancode/515643 to your computer and use it in GitHub Desktop.
<mt:ignore>
This template module is responsible for outputing the associated image with the current
photo/entry in context. You can pass in the max_size parameter to control the size of
the image.
Example:
<mt:getvar name="photo" max_size="90">
</mt:ignore>
<MTSetVarTemplate name="photo">
<MTSetVarBlock name="width" trim="1"><MTEntryAssets><MTAssetProperty property="image_width"></MTEntryAssets></MTSetVarBlock>
<MTSetVarBlock name="height" trim="1"><MTEntryAssets><MTAssetProperty property="image_height"></MTEntryAssets></MTSetVarBlock>
<mt:if name="width" gt="$height">
<mt:if name="width" gt="$max_size">
<MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink width="$max_size" regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
<mt:else>
<MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink width="$width" regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
</mt:if>
<mt:else>
<mt:if name="height" gt="$max_size">
<MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink height="$max_size" regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
<mt:else>
<MTSetVarBlock name="img"><MTEntryAssets><mt:AssetThumbnailLink height="$height" regex_replace="/^<a[^>]*>(<img[^>]*>)<\/a>$/","$1" /></MTEntryAssets></MTSetVarBlock>
</mt:if>
</mt:if>
<mt:getvar name="img" trim="1">
</MTSetVarTemplate>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment