"""
return cleaned_markdown_conversion(self.description)
- def get_display_media(self, media_map,
- fetch_order=common.DISPLAY_IMAGE_FETCHING_ORDER):
+ def get_display_media(self, fetch_order=None):
"""
Find the best media for display.
Args:
- - media_map: a dict like
- {u'image_size': [u'dir1', u'dir2', u'image.jpg']}
- - fetch_order: the order we should try fetching images in
+ - fetch_order: the order we should try fetching images in.
+ If this isn't supplied, we try checking
+ self.media_data.fetching_order if it exists.
Returns:
- (media_size, media_path)
+ (media_size, media_path)
+ or, if not found, None.
"""
- media_sizes = media_map.keys()
+ fetch_order = self.media_manager.get("media_fetch_order")
- for media_size in common.DISPLAY_IMAGE_FETCHING_ORDER:
+ # No fetching order found? well, give up!
+ if not fetch_order:
+ return None
+
+ media_sizes = self.media_files.keys()
+
+ for media_size in fetch_order:
if media_size in media_sizes:
- return media_map[media_size]
+ return media_size, self.media_files[media_size]
def main_mediafile(self):
pass
"sniff_handler": sniff_handler,
"display_template": "mediagoblin/media_displays/image.html",
"default_thumb": "images/media_thumbs/image.png",
- "accepted_extensions": ["jpg", "jpeg", "png", "gif", "tiff"]}
+ "accepted_extensions": ["jpg", "jpeg", "png", "gif", "tiff"],
+
+ # Used by the media_entry.get_display_media method
+ "media_fetch_order": [u'medium', u'original', u'thumb'],
+}
"display_template": "mediagoblin/media_displays/video.html",
"default_thumb": "images/media_thumbs/video.jpg",
"accepted_extensions": [
- "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"]}
+ "mp4", "mov", "webm", "avi", "3gp", "3gpp", "mkv", "ogv", "m4v"],
+
+ # Used by the media_entry.get_display_media method
+ "media_fetch_order": [u'webm_640', u'original'],
+}
{% set model_download = request.app.public_store.file_url(
- media.get_display_media(media.media_files)) %}
+ media.media_files['original']) %}
{% set perspective_view = request.app.public_store.file_url(
media.media_files['perspective']) %}
{% set top_view = request.app.public_store.file_url(
data-setup='{"height": {{ media.media_data.height }},
"width": {{ media.media_data.width }} }'>
<source src="{{ request.app.public_store.file_url(
- media.media_files['webm_640']) }}"
+ media.get_display_media()[1]) }}"
type="video/webm; codecs="vp8, vorbis"" />
<div class="no_html5">
{%- trans -%}Sorry, this video will not work because
<li><a href="{{ request.app.public_store.file_url(
media.media_files.original) }}">{% trans %}Original file{% endtrans %}</a>
{% endif %}
- <li><a href="{{ request.app.public_store.file_url(
- media.media_files.webm_640) }}">{% trans %}WebM file (640p; VP8/Vorbis){% endtrans %}</a>
+ {% if 'webm_640' in media.media_files %}
+ <li><a href="{{ request.app.public_store.file_url(
+ media.media_files.webm_640) }}">{% trans %}WebM file (640p; VP8/Vorbis){% endtrans %}</a>
+ {% endif %}
</ul>
{% endblock %}
<div class="media_image_container">
{% block mediagoblin_media %}
{% set display_media = request.app.public_store.file_url(
- media.get_display_media(media.media_files)) %}
+ media.get_display_media()[1]) %}
{# if there's a medium file size, that means the medium size
# isn't the original... so link to the original!
#}
import sys
-DISPLAY_IMAGE_FETCHING_ORDER = [u'medium', u'original', u'thumb']
global TESTS_ENABLED
TESTS_ENABLED = False