0

モデルにサムネイルの切り抜き元を指定するフィールドを追加しましたが、テンプレートタグに追加できないようです。

これが私が今それをする方法です:

  {% if entry.main_image.crop_value == "center" %}
   {% thumbnail entry.main_image.image "350x100" crop="center" as im %}
        <a href="{{ entry.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""></a>
    {% endthumbnail %}
  {% elif entry.main_image.crop_value == "top" %}
   {% thumbnail entry.main_image.image "350x100" crop="top" as im %}
        <a href="{{ entry.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""></a>
    {% endthumbnail %}
  {% elif entry.main_image.crop_value == "bottom" %}
   {% thumbnail entry.main_image.image "350x100" crop="bottom" as im %}
        <a href="{{ entry.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" alt=""></a>
    {% endthumbnail %}
  {% endif %}

これはそれを行うための最良の方法ではありませんか?

4

1 に答える 1

2

テンプレートタグで変数を使用できます。

{% thumbnail entry.main_image.image "350x100" crop=entry.main_image.crop_value as im %}
于 2012-10-15T20:16:56.333 に答える