Display type icon in thumbnails
authorBoris Bobrov <breton@cynicmansion.ru>
Fri, 15 Aug 2014 23:18:12 +0000 (02:18 +0300)
committerBoris Bobrov <breton@cynicmansion.ru>
Fri, 5 Feb 2016 02:30:28 +0000 (05:30 +0300)
mediagoblin/db/mixin.py
mediagoblin/media_types/video/__init__.py
mediagoblin/static/css/base.css
mediagoblin/templates/mediagoblin/utils/object_gallery.html

index ecd04874f39b4fee5341aa89ac072f51f05c4e8f..083617d3c1c47b7c1a404b61310f99323213a0a5 100644 (file)
@@ -301,6 +301,15 @@ class MediaEntryMixin(GenerateSlugMixin, GeneratePublicIDMixin):
             self.media_files[u"original"]
             )
 
+    @property
+    def icon_url(self):
+        '''Return the icon URL (for usage in templates) if it exists'''
+        try:
+            return self._app.staticdirector(
+                    self.media_manager['type_icon'])
+        except AttributeError:
+            return None
+
     @cached_property
     def media_manager(self):
         """Returns the MEDIA_MANAGER of the media's media_type
@@ -449,7 +458,7 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin):
         """ Adds an object to the collection """
         # It's here to prevent cyclic imports
         from mediagoblin.db.models import CollectionItem
-        
+
         # Need the ID of this collection for this so check we've got one.
         self.save(commit=False)
 
@@ -457,16 +466,16 @@ class CollectionMixin(GenerateSlugMixin, GeneratePublicIDMixin):
         item = CollectionItem()
         item.collection = self.id
         item.get_object = obj
-        
+
         if content is not None:
             item.note = content
 
         self.num_items = self.num_items + 1
-        
+
         # Save both!
         self.save(commit=commit)
         item.save(commit=commit)
-        return item 
+        return item
 
 class CollectionItemMixin(object):
     @property
index f636f1ab8bb84eb53e60673998c15cdb5f6e8c53..0b460d2929638db5c295fb543d1d311022a770e3 100644 (file)
@@ -28,6 +28,7 @@ class VideoMediaManager(MediaManagerBase):
     human_readable = "Video"
     display_template = "mediagoblin/media_displays/video.html"
     default_thumb = "images/media_thumbs/video.jpg"
+    type_icon = "images/type_icons/video.jpg"
 
     # Used by the media_entry.get_display_media method
     media_fetch_order = [u'webm_video', u'original']
index 52c1f2dc1895dbe84bf35443b1b6bcb312f0b939..5bbc1f748a54910f251eb1522afa6f4ed767dcbd 100644 (file)
@@ -590,6 +590,7 @@ ul#action_to_resolve {list-style:none; margin-left:10px;}
   border-color: #0D0D0D;
   border-style: solid;
   border-width: 1px 1px 2px;
+  position: relative;
 }
 
 .media_thumbnail a {
@@ -607,12 +608,11 @@ a.thumb_entry_title {
   padding: 8px;
 }
 
-/* For now, this is commented out since our thumbnails are actually 180px high.
- *
- * .media_thumbnail img {
- *   max-height: 135px;
- * }
- */
+.entry_type_icon {
+  position: absolute;
+  top: 0;
+  right: 0;
+}
 
 .thumb_entry_last {
   margin-right: 0px;
index 1f05eed209d8da9dffe3968717d23e8e198848b6..396d29975fd543210a9946ba201271fda935e542 100644 (file)
                      {%- if loop.first %} thumb_entry_first
                      {%- elif loop.last %} thumb_entry_last{% endif %}">
             <a href="{{ entry_url }}">
+              {% if entry.icon_url %}
+              <img class="entry_type_icon" src="{{ entry.icon_url }}" />
+              {% endif %}
               <img src="{{ entry.thumb_url }}" />
             </a>
             {% if entry.title %}
-              <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>
+            <a class="thumb_entry_title" href="{{ entry_url }}">{{ entry.title }}</a>
+            {{ entry.icon_url }}
             {% endif %}
           </div>
         {% endfor %}