Commit c6b9c2f9 authored by Seb's avatar Seb
Browse files

Fixed areas that would fail if no thumbnail is found for the video

parent e998fd3b
...@@ -17,7 +17,13 @@ ...@@ -17,7 +17,13 @@
{% for video in videos %} {% for video in videos %}
<li> <li>
<a class="image-choice" href="{% if will_select_format %}{% url 'wagtailvideos:chooser_select_format' video.id %}{% else %}{% url 'wagtailvideos:video_chosen' video.id %}{% endif %}"> <a class="image-choice" href="{% if will_select_format %}{% url 'wagtailvideos:chooser_select_format' video.id %}{% else %}{% url 'wagtailvideos:video_chosen' video.id %}{% endif %}">
<div class="image"><img src='{{video.thumbnail.url}}' width="165" height="165" class="show-transparency"></div> <div class="image">
{% if video.thumbnail %}
<img src='{{video.thumbnail.url}}' width="165" height="165" class="show-transparency">
{% else %}
<img width="165" height="165" class="show-transparency">
{% endif %}
</div>
<h3>{{ video.title|ellipsistrim:60 }}</h3> <h3>{{ video.title|ellipsistrim:60 }}</h3>
</a> </a>
</li> </li>
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
</ul> </ul>
</form> </form>
<div data-video-thumb="{{ video.id }}" class='thumb icon icon-image hasthumb'> <div data-video-thumb="{{ video.id }}" class='thumb icon icon-image hasthumb'>
{% if video.thumbnail %}
<img src="{{ video.thumbnail.url }}" /> <img src="{{ video.thumbnail.url }}" />
{% endif %}
</div> </div>
<script> <script>
......
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
<li> <li>
<a class="image-choice" href="{% url 'wagtailvideos:edit' video.id %}"> <a class="image-choice" href="{% url 'wagtailvideos:edit' video.id %}">
<div class="image"> <div class="image">
{% if video.thumbnail %}
<img src='{{video.thumbnail.url}}' height=165 width=165 class="show-transparency" /></img> <img src='{{video.thumbnail.url}}' height=165 width=165 class="show-transparency" /></img>
</div> {% endif %}
</div>
<h3>{{ video.title|ellipsistrim:60 }}</h3> <h3>{{ video.title|ellipsistrim:60 }}</h3>
</a> </a>
</li> </li>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
{% block chosen_state_view %} {% block chosen_state_view %}
<div class="video-thumb"> <div class="video-thumb">
{% if video %} {% if video and video.thumbnail %}
<img src='{{video.thumbnail.url}}' width="165" height="165" class="show-transparency"> <img src='{{video.thumbnail.url}}' width="165" height="165" class="show-transparency">
{% else %} {% else %}
<img width="165" height="165" class="show-transparency"> <img width="165" height="165" class="show-transparency">
......
...@@ -41,7 +41,8 @@ class VideoNode(template.Node): ...@@ -41,7 +41,8 @@ class VideoNode(template.Node):
if not video: if not video:
raise template.TemplateSyntaxError("video tag requires a Video object as the first parameter") raise template.TemplateSyntaxError("video tag requires a Video object as the first parameter")
self.attrs['poster'] = video.thumbnail.url if video.thumbnail:
self.attrs['poster'] = video.thumbnail.url
mime = mimetypes.MimeTypes() mime = mimetypes.MimeTypes()
sources = ["<source src='{0}' type='{1}'>" sources = ["<source src='{0}' type='{1}'>"
......
...@@ -30,7 +30,7 @@ def get_video_json(video): ...@@ -30,7 +30,7 @@ def get_video_json(video):
'edit_link': reverse('wagtailvideos:edit', args=(video.id,)), 'edit_link': reverse('wagtailvideos:edit', args=(video.id,)),
'title': video.title, 'title': video.title,
'preview': { 'preview': {
'url': video.thumbnail.url, 'url': video.thumbnail.url if video.thumbnail else '',
} }
}) })
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment