adds media thumbnail
This commit is contained in:
parent
1b9b6a6f15
commit
191087a1e4
|
@ -5,16 +5,24 @@ use Omeka\Api\Request;
|
||||||
use Omeka\Entity\Media;
|
use Omeka\Entity\Media;
|
||||||
use Omeka\Media\Ingester\IngesterInterface;
|
use Omeka\Media\Ingester\IngesterInterface;
|
||||||
use Omeka\Stdlib\ErrorStore;
|
use Omeka\Stdlib\ErrorStore;
|
||||||
|
use Omeka\File\Downloader;
|
||||||
use Zend\Form\Element\Text;
|
use Zend\Form\Element\Text;
|
||||||
use Zend\Http\Client;
|
use Zend\Http\Client;
|
||||||
use Zend\View\Renderer\PhpRenderer;
|
use Zend\View\Renderer\PhpRenderer;
|
||||||
|
|
||||||
class SketchfabMediaIngester implements IngesterInterface
|
class SketchfabMediaIngester implements IngesterInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Downloader
|
||||||
|
*/
|
||||||
|
protected $downloader;
|
||||||
protected $client;
|
protected $client;
|
||||||
public function __construct($client)
|
|
||||||
|
public function __construct($client, Downloader $downloader)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
|
$this->downloader = $downloader;
|
||||||
}
|
}
|
||||||
public function getLabel()
|
public function getLabel()
|
||||||
{
|
{
|
||||||
|
@ -54,8 +62,14 @@ class SketchfabMediaIngester implements IngesterInterface
|
||||||
));
|
));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$response_body = json_decode($response->getBody());
|
||||||
|
$thumbnail_url = $response_body->thumbnail_url;
|
||||||
|
$tempFile = $this->downloader->download($thumbnail_url);
|
||||||
|
if ($tempFile) {
|
||||||
|
$tempFile->mediaIngestFile($media, $request, $errorStore, false);
|
||||||
|
}
|
||||||
// Set the Media source and data.
|
// Set the Media source and data.
|
||||||
$media->setSource($data['o:source']);
|
$media->setSource($data['o:source']);
|
||||||
$media->setData(json_decode($response->getBody(), true));;
|
$media->setData($response_body, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,9 @@ class SketchfabMediaFactory implements FactoryInterface
|
||||||
$requestedName,
|
$requestedName,
|
||||||
array $options = null)
|
array $options = null)
|
||||||
{
|
{
|
||||||
return new SketchfabMediaIngester($services->get('Omeka\HttpClient'));
|
return new SketchfabMediaIngester(
|
||||||
|
$services->get('Omeka\HttpClient'),
|
||||||
|
$services->get('Omeka\File\Downloader')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue