Feature #506: link to original sized image if we scaled the image down.
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 22 Aug 2011 04:39:59 +0000 (23:39 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 22 Aug 2011 04:39:59 +0000 (23:39 -0500)
mediagoblin/templates/mediagoblin/user_pages/media.html

index 2086d3d60f9b53692518f3fc4e2cbe54af9969ac..6747fddc59e7eeab45505c78491ad07f2a9845e4 100644 (file)
   {% if media %}
     <div class="grid_11 alpha">
       <div class="media_image_container">
-        <img class="media_image"
-             src="{{ request.app.public_store.file_url(
-                         media.get_display_media(media.media_files)) }}" />
+        {% set display_media = request.app.public_store.file_url(
+                 media.get_display_media(media.media_files)) %}
+
+        {# if there's a medium file size, that means the medium size
+         #  isn't the original... so link to the original!
+         #}
+        {% if media['media_files'].has_key('medium') %}
+          <a href="{{ request.app.public_store.file_url(
+                        media['media_files']['original']) }}">
+            <img class="media_image"
+                 src="{{ display_media }}"
+                 alt="Image for {{ media.title }}" />
+          </a>
+        {% else %}
+          <img class="media_image"
+               src="{{ display_media }}"
+               alt="Image for {{ media.title }}" />
+        {% endif %}
       </div>
 
       <h2 class="media_title">