【发布时间】:2016-04-10 11:10:21
【问题描述】:
我正在使用 django 嵌入视频,所以当用户放置 youtube 链接视频时,我可以使用视频的缩略图
<img src="{{ my_video.thumbnail }}" class="img-rounded" alt="☺" height="75" width="75"/>
但是当用户插入不是 youtube 视频的链接时,我想插入默认图片。
目前这就是我所拥有的
{% if post.main_image %} //if post has main_image
<img src="{{post.get_image_url}}" class="img-rounded" alt="☺" height="75" width="75"/>
{% elif post.url %} //if post has url
{% video post.video as my_video %}
{% if my_video %}//if that url is an link to video
<img src="{{ my_video.thumbnail }}" class="img-rounded" alt="☺" height="75" width="75"/>
{% elif %} //if that url isn't a video
<img src="{{post.image}}" class="img-rounded" alt="☺ EBAGU" height="75" width="75"/>
{% endif %}
{% endvideo %}
{% else %} //if it doesn't have main_image or link
<img src="{{post.thumbnail}}" class="img-rounded" alt="☺" height="75" width="75"/>
{% endif %}
我得到上面的代码
TemplateSyntaxError at /post/aa-2/
Unexpected end of expression in if tag.
在 {% if my_video%}
谁能帮帮我
这是一个嵌入视频应用的链接-> http://django-embed-video.readthedocs.org/en/v1.1.0/examples.html#template-examples
【问题讨论】: