{% set thumbSize = 100 %} {% set maxThumbWidth = thumbSize %} {% set maxThumbHeight = "%d"|format(maxThumbWidth * 2/3) %}
{% set thumbCss = '' %} {% set hiResThumbCss = '' %} {% for file in files %} {% if file.kind == 'image' %} {% set thumbData = file.getThumbData(maxThumbWidth, maxThumbHeight) %} {% set topMargin = "%d"|format((thumbSize - thumbData.height) / 2) %} {% set bottomMargin = thumbSize - thumbData.height - topMargin %} {% set leftMargin = "%d"|format((thumbSize - thumbData.width) / 2) %} {% set rightMargin = thumbSize - thumbData.width - leftMargin %} {% set thumbCss = thumbCss ~'.thumb-wrapper.wrapper-'~file.id~' { margin: '~topMargin~'px '~rightMargin~'px '~bottomMargin~'px '~leftMargin~"px; }\n" %} {% set thumbCss = thumbCss ~ '.thumb-'~file.id~' { background-image: url('~thumbData.url~'); height: '~thumbData.height~'px; width: '~thumbData.width~"px;}\n" %} {% set hiResThumbCss = hiResThumbCss ~ '.thumb-'~file.id~' { background-image: url('~thumbData.url2X~'); background-size: '~thumbData.width~'px '~thumbData.height~"px; }\n" %} {% endif %} {% endfor %} {% includeCss thumbCss %} {% includeHiResCss hiResThumbCss %} {{ getHeadHtml() }}