forked from GNUsocial/gnu-social
[MEDIA][AttachmentThumbnail] Add mimetype to Entity
This commit is contained in:
parent
41dcef3c7b
commit
a5348f2427
@ -106,11 +106,11 @@ class ImageEncoder extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $event_map
|
* @param array $event_map
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function onResizerAvailable(&$event_map): bool
|
public function onResizerAvailable(array &$event_map): bool
|
||||||
{
|
{
|
||||||
$event_map['image'] = 'ResizeImagePath';
|
$event_map['image'] = 'ResizeImagePath';
|
||||||
return Event::next;
|
return Event::next;
|
||||||
@ -121,6 +121,7 @@ class ImageEncoder extends Plugin
|
|||||||
*
|
*
|
||||||
* @param array $vars
|
* @param array $vars
|
||||||
* @param array $res
|
* @param array $res
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function onViewAttachmentImage(array $vars, array &$res): bool
|
public function onViewAttachmentImage(array $vars, array &$res): bool
|
||||||
|
@ -57,11 +57,23 @@ class VideoEncoder extends Plugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $event_map
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function onResizerAvailable(array &$event_map): bool
|
||||||
|
{
|
||||||
|
//$event_map['video'] = 'ResizeVideoPath';
|
||||||
|
return Event::next;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the view for attachments of type Video
|
* Generates the view for attachments of type Video
|
||||||
*
|
*
|
||||||
* @param array $vars
|
* @param array $vars
|
||||||
* @param array $res
|
* @param array $res
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function onViewAttachmentVideo(array $vars, array &$res): bool
|
public function onViewAttachmentVideo(array $vars, array &$res): bool
|
||||||
|
@ -186,6 +186,7 @@ class AttachmentThumbnail extends Entity
|
|||||||
$ext = '.' . MimeTypes::getDefault()->getExtensions($temp->getMimeType())[0];
|
$ext = '.' . MimeTypes::getDefault()->getExtensions($temp->getMimeType())[0];
|
||||||
$filename = "{$predicted_width}x{$predicted_height}{$ext}-" . $attachment->getFileHash();
|
$filename = "{$predicted_width}x{$predicted_height}{$ext}-" . $attachment->getFileHash();
|
||||||
$thumbnail->setFilename($filename);
|
$thumbnail->setFilename($filename);
|
||||||
|
$thumbnail->setMimetype($mimetype);
|
||||||
DB::persist($thumbnail);
|
DB::persist($thumbnail);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
$temp->move(Common::config('thumbnail', 'dir'), $filename);
|
$temp->move(Common::config('thumbnail', 'dir'), $filename);
|
||||||
@ -302,7 +303,7 @@ class AttachmentThumbnail extends Entity
|
|||||||
'name' => 'attachment_thumbnail',
|
'name' => 'attachment_thumbnail',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'attachment_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Attachment.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'thumbnail for what attachment'],
|
'attachment_id' => ['type' => 'int', 'foreign key' => true, 'target' => 'Attachment.id', 'multiplicity' => 'one to one', 'not null' => true, 'description' => 'thumbnail for what attachment'],
|
||||||
// 'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
|
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
|
||||||
'width' => ['type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'],
|
'width' => ['type' => 'int', 'not null' => true, 'description' => 'width of thumbnail'],
|
||||||
'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'],
|
'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'],
|
||||||
'filename' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'thumbnail filename'],
|
'filename' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'thumbnail filename'],
|
||||||
|
Loading…
Reference in New Issue
Block a user