aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/mixin.py19
-rw-r--r--mediagoblin/media_types/image/__init__.py2
-rw-r--r--mediagoblin/static/images/media_thumbs/image.pngbin0 -> 30341 bytes
-rw-r--r--mediagoblin/templates/mediagoblin/edit/attachments.html3
-rw-r--r--mediagoblin/templates/mediagoblin/edit/edit.html5
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html9
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media_collect.html7
-rw-r--r--mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html9
-rw-r--r--mediagoblin/templates/mediagoblin/utils/collection_gallery.html5
-rw-r--r--mediagoblin/templates/mediagoblin/utils/object_gallery.html3
10 files changed, 37 insertions, 25 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index f6a15a12..22375b7f 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -27,6 +27,8 @@ These functions now live here and get "mixed in" into the
real objects.
"""
+import importlib
+
from mediagoblin import mg_globals
from mediagoblin.auth import lib as auth_lib
from mediagoblin.tools import common, licenses
@@ -112,6 +114,23 @@ class MediaEntryMixin(object):
media=self.slug_or_id,
**extra_args)
+ @property
+ def thumb_url(self):
+ """Return the thumbnail URL (for usage in templates)
+ Will return either the real thumbnail or a default fallback icon."""
+ # TODO: implement generic fallback in case MEDIA_MANAGER does
+ # not specify one?
+ if u'thumb' in self.media_files:
+ thumb_url = mg_globals.app.public_store.file_url(
+ self.media_files[u'thumb'])
+ else:
+ # no thumbnail in media available. Get the media's
+ # MEDIA_MANAGER for the fallback icon and return static URL
+ manager = importlib.import_module(self.media_type)
+ thumb_url = manager.MEDIA_MANAGER[u'default_thumb']
+ thumb_url = mg_globals.app.staticdirector(thumb_url) # use static
+ return thumb_url
+
def get_fail_exception(self):
"""
Get the exception that's appropriate for this error
diff --git a/mediagoblin/media_types/image/__init__.py b/mediagoblin/media_types/image/__init__.py
index d4720fab..36d7c201 100644
--- a/mediagoblin/media_types/image/__init__.py
+++ b/mediagoblin/media_types/image/__init__.py
@@ -24,5 +24,5 @@ MEDIA_MANAGER = {
# 'mediagoblin.media_types.image.processing'?
"sniff_handler": sniff_handler,
"display_template": "mediagoblin/media_displays/image.html",
- "default_thumb": "images/media_thumbs/image.jpg",
+ "default_thumb": "images/media_thumbs/image.png",
"accepted_extensions": ["jpg", "jpeg", "png", "gif", "tiff"]}
diff --git a/mediagoblin/static/images/media_thumbs/image.png b/mediagoblin/static/images/media_thumbs/image.png
new file mode 100644
index 00000000..8437a298
--- /dev/null
+++ b/mediagoblin/static/images/media_thumbs/image.png
Binary files differ
diff --git a/mediagoblin/templates/mediagoblin/edit/attachments.html b/mediagoblin/templates/mediagoblin/edit/attachments.html
index ee9d5cb7..976b1619 100644
--- a/mediagoblin/templates/mediagoblin/edit/attachments.html
+++ b/mediagoblin/templates/mediagoblin/edit/attachments.html
@@ -36,8 +36,7 @@
Editing attachments for {{ media_title }}
{%- endtrans %}</h1>
<div style="text-align: center;" >
- <img src="{{ request.app.public_store.file_url(
- media.media_files['thumb']) }}" />
+ <img src="{{ media.thumb_url }}" />
</div>
{% if media.attachment_files|count %}
diff --git a/mediagoblin/templates/mediagoblin/edit/edit.html b/mediagoblin/templates/mediagoblin/edit/edit.html
index 3e305ae0..144184df 100644
--- a/mediagoblin/templates/mediagoblin/edit/edit.html
+++ b/mediagoblin/templates/mediagoblin/edit/edit.html
@@ -34,8 +34,7 @@
<div class="form_box_xl edit_box">
<h1>{% trans media_title=media.title %}Editing {{ media_title }}{% endtrans %}</h1>
<div style="text-align: center;" >
- <img src="{{ request.app.public_store.file_url(
- media.media_files['thumb']) }}" />
+ <img src="{{ media.thumb_url }}" />
</div>
{{ wtforms_util.render_divs(form) }}
<div class="form_submit_buttons">
@@ -46,4 +45,4 @@
</div>
</form>
-{% endblock %}
+{% endblock %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html
index f56ab5ab..9be10321 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/collection_item_confirm_remove.html
@@ -33,14 +33,13 @@
Really remove {{ media_title }} from {{ collection_title }}?
{%- endtrans %}
</h1>
-
+
<div style="text-align: center;" >
- <img src="{{ request.app.public_store.file_url(
- collection_item.get_media_entry.media_files['thumb']) }}" />
+ <img src="{{ collection_item.get_media_entry.thumb_url }}" />
</div>
-
+
<br />
-
+
<p class="delete_checkbox_box">
{{ form.confirm }}
<label for="{{ (form.confirm.name) }}">{{ _(form.confirm.label.text) }}</label>
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html
index a56c9cd3..cefe638b 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media_collect.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media_collect.html
@@ -36,12 +36,11 @@
Add {{ title }} to collection
{%- endtrans %}
</h1>
-
+
<div style="text-align: center;" >
- <img src="{{ request.app.public_store.file_url(
- media.media_files['thumb']) }}" />
+ <img src="{{ media.thumb_url }}" />
</div>
-
+
<br />
<p class="form_field_label">
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html
index a3459206..a3cf0210 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html
@@ -31,14 +31,13 @@
Really delete {{ title }}?
{%- endtrans %}
</h1>
-
+
<div style="text-align: center;" >
- <img src="{{ request.app.public_store.file_url(
- media.media_files['thumb']) }}" />
+ <img src="{{ media.thumb_url }}" />
</div>
-
+
<br />
-
+
<p class="delete_checkbox_box">
{{ form.confirm }}
<label for="{{ (form.confirm.name) }}">{{ _(form.confirm.label.text) }}</label>
diff --git a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html
index a8742c74..5f8ffea1 100644
--- a/mediagoblin/templates/mediagoblin/utils/collection_gallery.html
+++ b/mediagoblin/templates/mediagoblin/utils/collection_gallery.html
@@ -31,10 +31,9 @@
{%- if loop.first %} thumb_entry_first
{%- elif loop.last %} thumb_entry_last{% endif %}">
<a href="{{ entry_url }}">
- <img src="{{ request.app.public_store.file_url(
- media_entry.media_files['thumb']) }}" />
+ <img src="{{ media_entry.thumb_url }}" />
</a>
-
+
{% if item.note %}
{%- trans note=item.note -%}
<br />
diff --git a/mediagoblin/templates/mediagoblin/utils/object_gallery.html b/mediagoblin/templates/mediagoblin/utils/object_gallery.html
index bfd19ee6..b4da5bc1 100644
--- a/mediagoblin/templates/mediagoblin/utils/object_gallery.html
+++ b/mediagoblin/templates/mediagoblin/utils/object_gallery.html
@@ -30,8 +30,7 @@
{%- if loop.first %} thumb_entry_first
{%- elif loop.last %} thumb_entry_last{% endif %}">
<a href="{{ entry_url }}">
- <img src="{{ request.app.public_store.file_url(
- entry.media_files['thumb']) }}" />
+ <img src="{{ entry.thumb_url }}" />
</a>
{% if entry.title %}
<a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>