+ $object = new ActivityObject();
+ $object->id = $this->getUri();
+ $object->type = ActivityObject::BOOKMARK;
+ $object->title = $this->getTitle();
+ $object->summary = $this->getDescription();
+ $object->link = $stored->getUrl();
+ $object->content = $stored->getRendered();
+
+ // Attributes of the URL
+
+ $attachments = $stored->attachments();
+
+ if (count($attachments) != 1) {
+ // TRANS: Server exception thrown when a bookmark has multiple attachments.
+ throw new ServerException(_m('Bookmark notice with the '.
+ 'wrong number of attachments.'));
+ }
+
+ $bookmarkedurl = $attachments[0];
+
+ $attrs = array('rel' => 'related',
+ 'href' => $bookmarkedurl->getUrl());
+
+ if (!strlen($bookmarkedurl->title)) {
+ $attrs['title'] = $bookmarkedurl->title;
+ }
+
+ $object->extra[] = array('link', $attrs, null);
+
+ // Attributes of the thumbnail, if any
+
+ try {
+ $thumbnail = $bookmarkedurl->getThumbnail();
+ $tattrs = array('rel' => 'preview',
+ 'href' => $thumbnail->getUrl());
+
+ if (!empty($thumbnail->width)) {
+ $tattrs['media:width'] = $thumbnail->width;
+ }
+
+ if (!empty($thumbnail->height)) {
+ $tattrs['media:height'] = $thumbnail->height;
+ }
+
+ $object->extra[] = array('link', $tattrs, null);
+ } catch (UnsupportedMediaException $e) {
+ // No image thumbnail metadata available
+ }
+
+ return $object;