[ATTACHMENTS][Embed][UI] Allow plugins to provide a title for an attachment, if a note has none, implement such a mechanism in Embed and cache the result, since it is potentially costly
This commit is contained in:
@@ -485,6 +485,17 @@ class Embed extends Plugin
|
||||
return HTTPClient::get($url)->getContent();
|
||||
}
|
||||
|
||||
public function onAttachmentGetBestTitle(Attachment $attachment, Note $note, ?string &$title)
|
||||
{
|
||||
try {
|
||||
$embed = DB::findOneBy('attachment_embed', ['attachment_id' => $attachment->getId()]);
|
||||
$title = $embed->getTitle();
|
||||
return Event::stop;
|
||||
} catch (NotFoundException) {
|
||||
}
|
||||
return Event::next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event raised when GNU social polls the plugin for information about it.
|
||||
* Adds this plugin's version information to $versions array
|
||||
|
Reference in New Issue
Block a user