{% macro format(thumbnail, b_w, extraclass, b_h)%}
	{% set b_width = b_w %}
	{% set b_height = b_h|default(b_width) %}
	
	{% set b_ratio = b_width / b_height %}
	{% set i_ratio = thumbnail.width / thumbnail.height %}
	
	{% if i_ratio > b_ratio%}
		{% if b_width > thumbnail.width %}
			{% set d_width = thumbnail.width %}
		{% else %}
			{% set d_width = b_width %}
		{% endif %}
		{% set d_height = d_width / thumbnail.width * thumbnail.height %}
		{% set top = (b_height - d_height) / 2 %}
	{% else %}
		{% if b_height > thumbnail.height %}
			{% set d_height = thumbnail.height %}
		{% else %}
			{% set d_height = b_height %}
		{% endif %}
		{% set d_width = d_height * thumbnail.width / thumbnail.height %}
		{% set top = ((b_height - d_height) / 2) %}
	{% endif %}
	<div style="width:{{b_width|round}}px;height:{{b_height|round}}px;" class="thumb_wrapper">
		<img ondragstart="return false;" src="{{thumbnail.url}}" class="thumb {{extraclass|default('')}}" style="width:{{d_width|round}}px;height:{{d_height|round}}px;top:{{top|round}}px;"/>
	</div>
{% endmacro %}