Add image URL's (thumb & full)
This commit is contained in:
parent
c8bd2542d7
commit
5b014a0866
@ -202,6 +202,17 @@ class MediaEntryMixin(GenerateSlugMixin):
|
|||||||
thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb'])
|
thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb'])
|
||||||
return thumb_url
|
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
|
@cached_property
|
||||||
def media_manager(self):
|
def media_manager(self):
|
||||||
"""Returns the MEDIA_MANAGER of the media's media_type
|
"""Returns the MEDIA_MANAGER of the media's media_type
|
||||||
|
@ -455,6 +455,12 @@ class MediaEntry(Base, MediaEntryMixin):
|
|||||||
"displayName": self.title,
|
"displayName": self.title,
|
||||||
"objectType": self.objectType,
|
"objectType": self.objectType,
|
||||||
"url": url,
|
"url": url,
|
||||||
|
"image": {
|
||||||
|
"url": request.host_url + self.thumb_url[1:],
|
||||||
|
},
|
||||||
|
"fullImage":{
|
||||||
|
"url": request.host_url + self.original_url[1:],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if show_comments:
|
if show_comments:
|
||||||
|
@ -2,7 +2,7 @@ from mediagoblin.decorators import oauth_required
|
|||||||
from mediagoblin.db.models import User, MediaEntry
|
from mediagoblin.db.models import User, MediaEntry
|
||||||
from mediagoblin.tools.response import json_response
|
from mediagoblin.tools.response import json_response
|
||||||
|
|
||||||
#@oauth_required
|
@oauth_required
|
||||||
def user(request):
|
def user(request):
|
||||||
""" Handles user response at /api/user/<username>/ """
|
""" Handles user response at /api/user/<username>/ """
|
||||||
user = request.matchdict["username"]
|
user = request.matchdict["username"]
|
||||||
@ -39,7 +39,7 @@ def inbox(request):
|
|||||||
""" Handles the user's inbox - /api/user/<username>/inbox """
|
""" Handles the user's inbox - /api/user/<username>/inbox """
|
||||||
raise NotImplemented("Yet to implement looking up user's inbox")
|
raise NotImplemented("Yet to implement looking up user's inbox")
|
||||||
|
|
||||||
#@oauth_required
|
@oauth_required
|
||||||
def object(request):
|
def object(request):
|
||||||
""" Lookup for a object type """
|
""" Lookup for a object type """
|
||||||
objectType = request.matchdict["objectType"]
|
objectType = request.matchdict["objectType"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user