diff options
author | Jessica Tallon <jessica@megworld.co.uk> | 2014-12-11 11:29:03 +0000 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2014-12-11 11:52:34 +0000 |
commit | 4a09d5956aed00b6dbc1dea53e217bee1f9dc0f0 (patch) | |
tree | f074c00e453227b9e5f288c14a37c5df0b1d2872 /mediagoblin/db | |
parent | f2698759cd291512b458c9d785c7c67ec9630ee2 (diff) | |
download | mediagoblin-4a09d5956aed00b6dbc1dea53e217bee1f9dc0f0.tar.lz mediagoblin-4a09d5956aed00b6dbc1dea53e217bee1f9dc0f0.tar.xz mediagoblin-4a09d5956aed00b6dbc1dea53e217bee1f9dc0f0.zip |
Fix #1053 - Add height and width attributes and MetadataProcess task
Added "height" and "width" attributes to "image" and "fullImage"
in the API where possible. The height and width of images wasn't
being stored anywhere so I've created a task to add or update
the metadata on images and also started adding those to new images
when they're submitted in the InitialProcessor.
Diffstat (limited to 'mediagoblin/db')
-rw-r--r-- | mediagoblin/db/models.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 98a91ccc..440aa682 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -591,6 +591,22 @@ class MediaEntry(Base, MediaEntryMixin): ), } + # Add image height and width if possible. We didn't use to store this + # data and we're not able (and maybe not willing) to re-process all + # images so it's possible this might not exist. + if self.get_file_metadata("thumb", "height"): + height = self.get_file_metadata("thumb", "height") + context["image"]["height"] = height + if self.get_file_metadata("thumb", "width"): + width = self.get_file_metadata("thumb", "width") + context["image"]["width"] = width + if self.get_file_metadata("original", "height"): + height = self.get_file_metadata("original", "height") + context["fullImage"]["height"] = height + if self.get_file_metadata("original", "height"): + width = self.get_file_metadata("original", "width") + context["fullImage"]["width"] = width + return context def unserialize(self, data): |