你好可以像这样使用django模板语言和javascript:
{% if post.main_image %}
<img src="{{post.get_image_url}}" class="img-rounded" alt="☺" height="75" width="75"/>
{% elif post.url %}
{% video post.url as my_video %}
<img src="{{ my_video.thumbnail }}" id="myThumb" class="img-rounded" alt="☺" height="75" width="75"/>
{% endvideo %}
{% else %}
<img src="{{post.thumbnail}}" class="img-rounded" alt="☺" height="75" width="75"/>
{% endif %}
<script>
$(document).ready(function() {
var i = $('mythumb'); // using an id <img id='mythumb'.....
if( i.width === 0 ) i.src='<img src="{{post.image}}" class="img-rounded" alt="☺ EBAGU" height="75" width="75"/>';
}
</script>