mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
Fix #1414 Add immediate thumbnail substitution after success download
This commit is contained in:
@@ -13,6 +13,8 @@ namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Attribute\Status;
|
||||
use DataURI;
|
||||
use DataURI\Exception\Exception as DataUriException;
|
||||
use Entities\LazaretSession;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
@@ -243,6 +245,30 @@ class Upload implements ControllerProviderInterface
|
||||
$element = 'record';
|
||||
$message = _('The record was successfully created');
|
||||
$app['phraseanet.SE']->addRecord($elementCreated);
|
||||
|
||||
// try to create thumbnail from data URI
|
||||
if ('' !== $b64Image = $request->request->get('b64_image', '')) {
|
||||
try {
|
||||
$dataUri = DataURI\Parser::parse($b64Image);
|
||||
|
||||
$fileName = sprintf('%s/tmp/%s.png', $app['root.path'], sprintf('base_64_thumb_%s', $id));
|
||||
file_put_contents($fileName, $dataUri->getData());
|
||||
|
||||
$media = $app['mediavorus']->guess($fileName);
|
||||
$elementCreated->substitute_subdef('thumbnail', $media, $app);
|
||||
$app['phraseanet.logger']($elementCreated->get_databox())->log(
|
||||
$elementCreated,
|
||||
\Session_Logger::EVENT_SUBSTITUTE,
|
||||
'thumbnail',
|
||||
''
|
||||
);
|
||||
|
||||
unset($media);
|
||||
$app['filesystem']->remove($fileName);
|
||||
} catch (DataUriException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$params = array('lazaret_file' => $elementCreated);
|
||||
|
||||
|
@@ -336,6 +336,7 @@ $(document).ready(function () {
|
||||
UploaderManager.Preview.render(file, function(img){
|
||||
context.find('.thumbnail .canva-wrapper').prepend(img);
|
||||
UploaderManager.addAttributeToData(uploadIndex, 'image', img);
|
||||
UploaderManager.addAttributeToData(uploadIndex, 'b64_image', img.toDataURL("image/png") || '');
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -390,6 +391,11 @@ $(document).ready(function () {
|
||||
$("select", UploaderManager.getSettingsBox()).serializeArray()
|
||||
);
|
||||
|
||||
data.formData.push({
|
||||
"name": "b64_image",
|
||||
"value": data["b64_image"]
|
||||
});
|
||||
|
||||
//remove current context
|
||||
data.context.remove();
|
||||
|
||||
|
Reference in New Issue
Block a user