diff --git a/pandora/backend/models.py b/pandora/backend/models.py index 66df8db3b..557b39e79 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -148,7 +148,9 @@ class Movie(models.Model): if self.poster: self.poster_height = self.poster.height self.poster_width = self.poster.width - + else: + self.poster_height = 128 + self.poster_width = 80 super(Movie, self).save(*args, **kwargs) self.updateFind() self.updateSort() diff --git a/pandora/backend/urls.py b/pandora/backend/urls.py index 477479b78..9d91372cc 100644 --- a/pandora/backend/urls.py +++ b/pandora/backend/urls.py @@ -9,6 +9,7 @@ urlpatterns = patterns("backend.views", (r'^(?P.*)/(?P.*.webm)$', 'video'), (r'^(?P.*)/(?P.*.mp4)$', 'video'), (r'^(?P.*)/poster\.(?P\d+)\.jpg$', 'poster'), + (r'^(?P.*)/poster\.(?Plarge)\.jpg$', 'poster'), (r'^(?P.*)/poster\.jpg$', 'poster'), (r'^(?P.*)/timelines/(?P.+)\.(?P\d+)\.(?P\d+)\.png$', 'timeline'), (r'^(?P.*)/data/(?P.+)\.json$', 'data'), diff --git a/pandora/static/js/pandora.js b/pandora/static/js/pandora.js index a3e9f2312..fbe5db673 100755 --- a/pandora/static/js/pandora.js +++ b/pandora/static/js/pandora.js @@ -516,13 +516,20 @@ app.constructList = function(view) { id: 'list', item: function(data, sort, size) { size = size || 128; + if(data.poster.height>data.poster.width) { + var height = size, + width = height * data.poster.width / data.poster.height; + } else { + var width = size, + height = width * data.poster.height / data.poster.width; + } return { - height: data.poster.height || 128, // fixme: remove later + height: height, id: data['id'], info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key], title: data.title + (data.director ? ' (' + data.director + ')' : ''), url: data.poster.url.replace(/jpg$/, size + '.jpg'), - width: data.poster.width || 80 // fixme: remove later + width: width }; }, keys: keys, @@ -559,7 +566,7 @@ app.constructList = function(view) { }, openpreview: function(event, data) { app.request('find', { - keys: ['director', 'id', 'posterHeight', 'posterWidth', 'posterURL', 'title'], + keys: ['director', 'id', 'poster', 'title'], query: { conditions: $.map(data.ids, function(id, i) { return { @@ -575,27 +582,14 @@ app.constructList = function(view) { title = item.title + (item.director ? ' (' + item.director + ')' : ''), documentHeight = app.$document.height(), dialogHeight = documentHeight - 40, - dialogWidth = parseInt((dialogHeight - 48) * 0.75), + dialogWidth = parseInt((dialogHeight - 48) * item.poster.width/item.poster.height), $image = $('') .attr({ - src: 'http://0xdb.org/' + item.id + '/poster.large.jpg' + src: item.poster.url.replace(/jpg/, 'large.jpg') }) .css({ - height: (dialogHeight - 48) + 'px', - width: dialogWidth + 'px' - }) - .load(function() { - var image = $image[0], - imageHeight = Math.min(image.height, documentHeight - 88), - imageWidth = parseInt(image.width * imageHeight / image.height); - app.$ui.previewDialog.options({ - height: imageHeight + 48, - width: imageWidth - }); - $image.css({ - height: imageHeight + 'px', - width: imageWidth + 'px' - }); + height: (dialogHeight - 48 -3) + 'px', + width: (dialogWidth - 3*item.poster.width/item.poster.height) + 'px' }); if ('previewDialog' in app.$ui) { app.$ui.previewDialog.options({