2018-10-26 08:34:13 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Data container for necessary Speech api media uploaduploads
|
|
|
|
*
|
|
|
|
* Visit https://github.com/lbryio/spee.ch for more info
|
|
|
|
*
|
|
|
|
* @package LBRYPress
|
|
|
|
*/
|
|
|
|
|
|
|
|
class LBRY_Speech_Media
|
|
|
|
{
|
2018-10-26 18:13:24 +02:00
|
|
|
public $id;
|
|
|
|
|
2018-10-26 08:34:13 +02:00
|
|
|
public $name;
|
|
|
|
|
|
|
|
public $file;
|
|
|
|
|
|
|
|
public $type;
|
|
|
|
|
|
|
|
public $nsfw;
|
|
|
|
|
|
|
|
public $license;
|
|
|
|
|
|
|
|
public $title;
|
|
|
|
|
|
|
|
public $description;
|
|
|
|
|
|
|
|
public $thumbnail;
|
|
|
|
|
2018-10-27 21:28:20 +02:00
|
|
|
private $is_image = false;
|
|
|
|
|
|
|
|
public function __construct(int $attachment_id, $args = array(), bool $is_image = false)
|
2018-10-26 08:34:13 +02:00
|
|
|
{
|
2018-10-26 09:43:34 +02:00
|
|
|
|
|
|
|
// Set supplied arguments
|
|
|
|
$default = array(
|
|
|
|
'nsfw' => null,
|
|
|
|
'license' => null,
|
|
|
|
'description' => null,
|
|
|
|
'thumbnail' => null
|
|
|
|
);
|
|
|
|
|
|
|
|
$settings = array_merge($default, array_intersect_key($args, $default));
|
|
|
|
|
|
|
|
foreach ($settings as $key => $value) {
|
|
|
|
$this->{$key} = $value;
|
|
|
|
}
|
|
|
|
|
2018-10-27 21:28:20 +02:00
|
|
|
// Flag as image if it is one
|
|
|
|
if ($is_image) {
|
|
|
|
$this->is_image = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // Get attachment ID, name, file, and type from the URL
|
|
|
|
// $url = strtok($url, '?'); // Clean up query params first
|
|
|
|
// $id = $this->rigid_attachment_url_to_postid($url);
|
|
|
|
$meta = wp_get_attachment_metadata($attachment_id);
|
|
|
|
error_log(print_r($meta, true));
|
2018-10-26 18:13:24 +02:00
|
|
|
$attachment = get_post($id);
|
|
|
|
$path = get_attached_file($id);
|
2018-10-27 21:28:20 +02:00
|
|
|
// $type = $attachment->post_mime_type;
|
|
|
|
// $filename = wp_basename($path);
|
|
|
|
//
|
|
|
|
// $this->id = $id;
|
|
|
|
// // COMBAK: Probably wont need this underscore check with Daemon V3
|
|
|
|
// $this->name = str_replace('_', '-', $attachment->post_name);
|
|
|
|
// $this->file = new CURLFile($path, $type, $filename);
|
|
|
|
// $this->type = $type;
|
|
|
|
// $this->title = $attachment->post_title;
|
2018-10-26 18:13:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-10-27 21:28:20 +02:00
|
|
|
public function is_image()
|
|
|
|
{
|
|
|
|
return $this->is_image;
|
2018-10-26 08:34:13 +02:00
|
|
|
}
|
|
|
|
}
|