Add image URL's (thumb & full)

This commit is contained in:
Jessica Tallon 2013-08-14 19:58:01 +01:00 committed by Jessica Tallon
parent c8bd2542d7
commit 5b014a0866
3 changed files with 19 additions and 2 deletions

View File

@ -202,6 +202,17 @@ class MediaEntryMixin(GenerateSlugMixin):
thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb'])
return thumb_url
@property
def original_url(self):
""" Returns the URL for the original image
will return self.thumb_url if original url doesn't exist"""
if u"original" not in self.media_files:
return self.thumb_url
return mg_globals.app.public_store.file_url(
self.media_files[u"original"]
)
@cached_property
def media_manager(self):
"""Returns the MEDIA_MANAGER of the media's media_type

View File

@ -455,6 +455,12 @@ class MediaEntry(Base, MediaEntryMixin):
"displayName": self.title,
"objectType": self.objectType,
"url": url,
"image": {
"url": request.host_url + self.thumb_url[1:],
},
"fullImage":{
"url": request.host_url + self.original_url[1:],
}
}
if show_comments:

View File

@ -2,7 +2,7 @@ from mediagoblin.decorators import oauth_required
from mediagoblin.db.models import User, MediaEntry
from mediagoblin.tools.response import json_response
#@oauth_required
@oauth_required
def user(request):
""" Handles user response at /api/user/<username>/ """
user = request.matchdict["username"]
@ -39,7 +39,7 @@ def inbox(request):
""" Handles the user's inbox - /api/user/<username>/inbox """
raise NotImplemented("Yet to implement looking up user's inbox")
#@oauth_required
@oauth_required
def object(request):
""" Lookup for a object type """
objectType = request.matchdict["objectType"]