diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-02-22 00:35:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-22 00:35:46 +0100 |
commit | 90f12f2e5a41115a9a756f9dd38054736080d4f9 (patch) | |
tree | 72af04d32879a08a620e306c3c15e1e2f7985f37 /app/serializers | |
parent | d3a62d263703142250d7d59335394a8e2a599ed4 (diff) |
Focal points (#6520)
* Add focus param to media API, center thumbnails on focus point * Add UI for setting a focal point * Improve focal point icon on upload item * Use focal point in upload preview * Add focalPoint property to ActivityPub * Don't show focal point button for non-image attachments
Diffstat (limited to 'app/serializers')
-rw-r--r-- | app/serializers/activitypub/image_serializer.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/serializers/activitypub/image_serializer.rb b/app/serializers/activitypub/image_serializer.rb index a015c6b1b..a3ac637b6 100644 --- a/app/serializers/activitypub/image_serializer.rb +++ b/app/serializers/activitypub/image_serializer.rb @@ -4,6 +4,7 @@ class ActivityPub::ImageSerializer < ActiveModel::Serializer include RoutingHelper attributes :type, :media_type, :url + attribute :focal_point, if: :focal_point? def type 'Image' @@ -16,4 +17,12 @@ class ActivityPub::ImageSerializer < ActiveModel::Serializer def media_type object.content_type end + + def focal_point? + object.responds_to?(:meta) && object.meta['focus'].is_a?(Hash) + end + + def focal_point + [object.meta['focus']['x'], object.meta['focus']['y']] + end end |