[MEDIA][AttachmentThumbnail] Add mimetype to Entity

This commit is contained in:
Diogo Peralta Cordeiro 2021-07-22 21:17:23 +01:00 committed by Hugo Sales
parent 41dcef3c7b
commit a5348f2427
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 21 additions and 7 deletions

View File

@ -106,11 +106,11 @@ class ImageEncoder extends Plugin
}
/**
* @param $event_map
* @param array $event_map
*
* @return bool
*/
public function onResizerAvailable(&$event_map): bool
public function onResizerAvailable(array &$event_map): bool
{
$event_map['image'] = 'ResizeImagePath';
return Event::next;
@ -121,6 +121,7 @@ class ImageEncoder extends Plugin
*
* @param array $vars
* @param array $res
*
* @return bool
*/
public function onViewAttachmentImage(array $vars, array &$res): bool

View File

@ -57,11 +57,23 @@ class VideoEncoder extends Plugin
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
*
* @param array $vars
* @param array $res
*
* @return bool
*/
public function onViewAttachmentVideo(array $vars, array &$res): bool

View File

@ -186,6 +186,7 @@ class AttachmentThumbnail extends Entity
$ext = '.' . MimeTypes::getDefault()->getExtensions($temp->getMimeType())[0];
$filename = "{$predicted_width}x{$predicted_height}{$ext}-" . $attachment->getFileHash();
$thumbnail->setFilename($filename);
$thumbnail->setMimetype($mimetype);
DB::persist($thumbnail);
DB::flush();
$temp->move(Common::config('thumbnail', 'dir'), $filename);
@ -302,7 +303,7 @@ class AttachmentThumbnail extends Entity
'name' => 'attachment_thumbnail',
'fields' => [
'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'],
'height' => ['type' => 'int', 'not null' => true, 'description' => 'height of thumbnail'],
'filename' => ['type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'thumbnail filename'],