mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 01:39:24 +02:00
Improve live poster upload
This commit is contained in:
parent
1fee8b996f
commit
c61088c7fa
6 changed files with 88 additions and 66 deletions
|
@ -23,8 +23,15 @@ $croppieFilesAdded = 1;
|
|||
<script>
|
||||
|
||||
var uploadCrop<?php echo $uid; ?>;
|
||||
|
||||
var createCroppie<?php echo $uid; ?>Timeout;
|
||||
function createCroppie<?php echo $uid; ?>(imageURL) {
|
||||
clearTimeout(createCroppie<?php echo $uid; ?>Timeout);
|
||||
if($('#croppie<?php echo $uid; ?>').is(":hidden")){
|
||||
createCroppie<?php echo $uid; ?>Timeout = setTimeout(function(){
|
||||
createCroppie<?php echo $uid; ?>(imageURL);
|
||||
},1000);
|
||||
return false;
|
||||
}
|
||||
console.log('createCroppie');
|
||||
uploadCrop<?php echo $uid; ?> = $('#croppie<?php echo $uid; ?>').croppie({
|
||||
//url: imageURL,
|
||||
|
|
|
@ -287,32 +287,6 @@ if (!empty($chat2) && !empty($chat2->useStaticLayout)) {
|
|||
});
|
||||
}
|
||||
$(document).ready(function () {
|
||||
$("#input-jpg").fileinput({
|
||||
uploadUrl: webSiteRootURL + "plugin/Live/uploadPoster.php?live_servers_id=<?php echo $_REQUEST['live_servers_id']; ?>",
|
||||
autoReplace: true,
|
||||
overwriteInitial: true,
|
||||
showUploadedThumbs: false,
|
||||
showPreview: true,
|
||||
maxFileCount: 1,
|
||||
initialPreview: [
|
||||
"<img class='img img-responsive' src='<?php echo $global['webSiteRootURL']; ?><?php echo $poster; ?>?<?php echo filectime($global['systemRootPath'] . $poster); ?>'>",
|
||||
],
|
||||
initialCaption: 'LiveBG.jpg',
|
||||
initialPreviewShowDelete: false,
|
||||
showRemove: false,
|
||||
showClose: false,
|
||||
layoutTemplates: {actionDelete: ''}, // disable thumbnail deletion
|
||||
allowedFileExtensions: ["jpg", "jpeg", "png"],
|
||||
//minImageWidth: 2048,
|
||||
//minImageHeight: 1152,
|
||||
//maxImageWidth: 2560,
|
||||
//maxImageHeight: 1440
|
||||
}).on('fileuploaded', function (event, previewId, index, fileId) {
|
||||
var poster = webSiteRootURL + '<?php echo Live::_getPosterImage(User::getId(), $_REQUEST['live_servers_id']); ?>?' + Math.random();
|
||||
$('#mainVideo video').attr('poster', poster);
|
||||
$('#mainVideo .vjs-poster').css('background-image', 'url("' + poster + '"');
|
||||
});
|
||||
|
||||
$('#removePoster').click(function () {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
|
|
|
@ -183,7 +183,44 @@ $key = $liveStreamObject->getKeyWithIndex(true);
|
|||
</button>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<input id="input-jpg" type="file" class="file-loading" accept="image/*">
|
||||
<?php
|
||||
$poster = Live::getPosterImage(User::getId(), $_REQUEST['live_servers_id']);
|
||||
$image = getURL($poster);
|
||||
$croppie1 = getCroppie(__("Upload Poster"), "saveLivePoster");
|
||||
echo $croppie1['html'];
|
||||
?>
|
||||
<hr>
|
||||
<button class="btn btn-success btn-lg btn-block" onclick="closeWindowAfterImageSave = true;<?php echo $croppie1['getCroppieFunction']; ?>"><i class="fas fa-save"></i> <?php echo __('Save'); ?></button>
|
||||
<script>
|
||||
var closeWindowAfterImageSave = false;
|
||||
function saveLivePoster(image) {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: webSiteRootURL + 'plugin/Live/uploadPoster.json.php?live_servers_id=<?php echo $_REQUEST['live_servers_id']; ?>',
|
||||
data: {
|
||||
image: image
|
||||
},
|
||||
type: 'post',
|
||||
success: function (response) {
|
||||
modal.hidePleaseWait();
|
||||
avideoResponse(response);
|
||||
if (response && !response.error) {
|
||||
if (closeWindowAfterImageSave) {
|
||||
avideoModalIframeClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
<?php
|
||||
echo $croppie1['createCroppie'] . "('{$image}');";
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
41
plugin/Live/uploadPoster.json.php
Normal file
41
plugin/Live/uploadPoster.json.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
require_once '../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Live/Objects/Live_schedule.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
|
||||
$plugin = AVideoPlugin::loadPluginIfEnabled('Live');
|
||||
|
||||
if (!User::canStream()) {
|
||||
$obj->msg = "You cant do this 1";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
|
||||
$live_servers_id = intval(@$_REQUEST['live_servers_id']);
|
||||
$live_schedule_id = intval(@$_REQUEST['live_schedule_id']);
|
||||
|
||||
if (!empty($live_schedule_id)) {
|
||||
$row = new Live_schedule($live_schedule_id);
|
||||
if (User::isAdmin() || $row->getUsers_id() == User::getId()) {
|
||||
if (isset($_REQUEST['image'])) {
|
||||
$image = Live_schedule::getPosterPaths($live_schedule_id);
|
||||
$obj->path = $image['path'];
|
||||
$obj->image = saveCroppieImage($obj->path, "image");
|
||||
$obj->error = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$obj->path = $global['systemRootPath'] . Live::_getPosterImage(User::getId(), $live_servers_id);
|
||||
$obj->image = saveCroppieImage($obj->path, "image");
|
||||
if ($obj->image) {
|
||||
$obj->pathThumbs = $global['systemRootPath'] . Live::_getPosterThumbsImage(User::getId(), $live_servers_id);
|
||||
@unlink($obj->pathThumbs);
|
||||
$obj->error = false;
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode($obj));
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once '../../../../videos/configuration.php';
|
||||
require_once $global['systemRootPath'] . 'plugin/Live/Objects/Live_schedule.php';
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj->error = true;
|
||||
|
||||
$plugin = AVideoPlugin::loadPluginIfEnabled('Live');
|
||||
|
||||
if (!User::canStream()) {
|
||||
$obj->msg = "You cant do this 1";
|
||||
die(json_encode($obj));
|
||||
}
|
||||
|
||||
|
||||
$live_schedule_id = intval($_REQUEST['live_schedule_id']);
|
||||
|
||||
if (empty($live_schedule_id)) {
|
||||
forbiddenPage("Invalid schedule ID");
|
||||
}
|
||||
|
||||
$row = new Live_schedule($live_schedule_id);
|
||||
|
||||
if (User::isAdmin() || $row->getUsers_id() == User::getId()) {
|
||||
if (isset($_REQUEST['image'])) {
|
||||
$image = Live_schedule::getPosterPaths($live_schedule_id);
|
||||
$obj->path = $image['path'];
|
||||
$obj->image = saveCroppieImage($obj->path, "image");
|
||||
$obj->error = false;
|
||||
}
|
||||
} else {
|
||||
$obj->msg = "You cant do this 2";
|
||||
}
|
||||
|
||||
die(json_encode($obj));
|
|
@ -47,7 +47,7 @@ $image = Live_schedule::getPosterURL($live_schedule_id);
|
|||
function saveSchedulePoster(image) {
|
||||
modal.showPleaseWait();
|
||||
$.ajax({
|
||||
url: webSiteRootURL + 'plugin/Live/view/Live_schedule/uploadPoster.json.php',
|
||||
url: webSiteRootURL + 'plugin/Live/uploadPoster.json.php',
|
||||
data: {
|
||||
live_schedule_id: <?php echo $live_schedule_id; ?>,
|
||||
image: image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue