I have working solr-thumbnail in several parts of my project, but this time I want to display an image from a URL, I have it like this:

    {% load thumbnail %}
    {% thumbnail profile_picture_url "150x150" crop="center" as img %}
    <img src="{{ img }}">
    {% endthumbnail %}

The view passes the value profile_picture_url as "http://....image.jpg". The image is correctly displayed if I just use:

<img src="{{ profile_picture_url }}">

What am I doing wrong ?

Thank you

有帮助吗?

解决方案

SORL-Thumbnail is looking for the image object, not the URL. Pass it profile_picture instead of profile_picture_url and then call the url attribute of img in the src attribute of the img tag.

{% load thumbnail %}
{% thumbnail profile_picture "150x150" crop="center" as img %}
  <img src="{{ img.url }}">
{% endthumbnail %}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top