-
Notifications
You must be signed in to change notification settings - Fork 0
server photo
Receive and manipulate user submitted photos.
Photo = require 'photo'
Db = require 'db'
exports.onPhoto = (info) !->
newInfo = Photo.crop {left: 100, right: 100, top: 100, bottom: 100}
Db.shared.set 'myPhotoKey', newInfo.key
This module (only) works in unison with the photo
client module. Check that page for a more extensive walkthrough.
Invoked when a photo is both claimed and uploaded. The info
object will have the same fields as returned from the get(key)
function.
Return false
to discard the photo. Otherwise, the return value is stored in the photo's data
field, included in the info object.
Gets photo info array for given key. The info array contains the following fields:
Key | Value |
---|---|
key | Photo key; when the key is known, users can view the image. |
type | Image type. Maps to the values returned by PHP's imageTypes() . |
userId | User id of the Happening member that submitted the photo. Can be 0. |
width | Unscaled image width. |
height | Unscaled image height. |
size | File size of the unscaled image. |
data | Custom data returned by onPhoto after claiming the photo. |
List of all photos uploaded to this plugin. When userId
is supplied, the list is filtered to only match photos for this user.
Delete photo original and all scaled versions.
Given a opts.guid
(which was obtained client-side), claim the photo for this plugin and fire a callback. The latter only happens after the photo has been fully received and processed - which may be never: an unfulfilled claim is discarded after a couple of days.
opts
consists of:
| guid | Identifier for the upload we are claiming. |
| url | When an URL is given instead of guid
, the image will be downloaded from this URL. Specifying a cb
is required in this case. It will be called with null
instead of the photo info object on failure. |
| cb | Array, where the first element is a server-side method name, and the rest are optional arguments. The photo info object is appended as the last argument. When the cb
key is not set, the legacy form onPhoto(infoHash)
will be called. |
| memberId | Which group member to attribute this photo to. If not set and we're called as a user RPC, the calling member is assumed. |
- [How it works](How it works)
- [Your first plugin](Your first plugin)
- Submitting and distributing your plugin
- Using the Developer Tools
- Example plugins on Github
-
API Reference
- Client
- [client plugin](client plugin)
- [client dom](client dom)
- [client obs](client obs)
- [client db](client db)
- [client server](client server)
- [client page](client page)
- [client ui](client ui)
- [client form](client form)
- [client icon](client icon)
- [client modal](client modal)
- [client photo](client photo)
- [client photoview](client photoview)
- [client time](client time)
- [client share](client share)
- [client map](client map)
- [client geoloc](client geoloc)
- Server
- [server event](server event)
- [server plugin](server plugin)
- [server http](server http)
- [server db](server db)
- [server photo](server photo)
- [server time](server time)
- Client
- Example UI elements