{% macro format(thumbnail, size, extraclass)%}
	{% if thumbnail.w > thumbnail.h%}
		{% if size > thumbnail.w %}
			{% set d_width = thumbnail.w %}
		{% else %}
			{% set d_width = size %}
		{% endif %}
		{% set d_height = d_width / thumbnail.w * thumbnail.h %}
		{% set top = (size - d_height) / 2 %}
	{% else %}
		{% if size > thumbnail.h %}
			{% set d_height = thumbnail.h %}
		{% else %}
			{% set d_height = size %}
		{% endif %}
		{% set d_width = d_height * thumbnail.w / thumbnail.h %}
		{% set top = 0 %}
	{% endif %}
	<div style="width:{{size|round}}px;height:{{size|round}}px;" class="thumb_wrapper">
		<img src="{{thumbnail.thumbnail}}" class="thumb {{extraclass|default('')}}" style="width:{{d_width|round}}px;height:{{d_height|round}}px;top:{{top|round}}px;"/>
	</div>
{% endmacro %}