Danlowe95 / IBEIS-web

Web interface and API for IBEIS.
Apache License 2.0
0 stars 6 forks source link

Workspace images load full sized images, when they could be loading thumbnails. #13

Open Danlowe95 opened 8 years ago

Danlowe95 commented 8 years ago

The wildbook database has a thumbnail field in mediaassets. I don't think it is automatically populated with a smaller-res file. If it is, great, change the workspace tile-images to use thumbnail for faster loading. If not, we should talk to JonV about getting thumbnail support for all images implemented.

naknomum commented 7 years ago

the short answer is: "there should be". :)

the long answer is, there almost always is. but you cant necessarily count on it. and thus should have a fallback. toward this end, i can present you with some code we have used (or maybe even currently are using). context: we have a kinda dusty implementation of some js code based on backbone.js ... i dont really have any kind allegiance to it, but use it when it suits me. probably better for you all to generally ignore it, except when you want to steal code from it. with that in mind, i present this:

http://springbreak.wildbook.org/javascript/classes/MediaAsset.js

in particular, labelUrl() might be of interest. "labels" are basically system-set tags on MediaAssets, which are kinda freeform. right now i mostly used them for roughly size (e.g. "_thumb") or the special case "_original" (uploaded by user). all that labelUrl does is return the mediaAsset.url of a matching child MediaAsset if available, otherwise fallback to one you pass in, presumably the "root" MediaAsset.url. (it does so in backbone-ese, but you should be able to modify for traversing plain old json object children, etc)

much like the previous "should have", most MediaAssets "should have" children assets in their json structure. but dont always. :) haha hit me up with questions about this if you have any.

naknomum commented 7 years ago

oh, and here are the "generally supported" size labels we have: _thumb (100x75), _watermark (250x200 with 'do not copy' text over), _mid (1024x768) ...

alabgold commented 7 years ago

@naknomum Im not sure where to put the code you gave us. I believe it should be in our wildbook.service.js file?

naknomum commented 7 years ago

i would simply suggest that whereever it is most convenient for you to be able to use in all the places you might need thumbnails. if wildbook.service.js is a sort of general purpose library, then yes, i think that would be great. i might suggest mimicking the functionality of what i shared -- that is to say, create a function you can pass in a MediaAsset and label and get back a url (even if that label-flavored url does not exist). that way you can kind of blindly trust you will get something back. you can re-use it later for, say, finding _mid sized images when you dont want the giant originals etc.

alabgold commented 7 years ago

okay I will try that, thanks!