mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 19:46:21 +05:30
Add insert image button
This commit is contained in:
parent
492acce7c2
commit
adfaf19cf1
5 changed files with 135 additions and 10 deletions
|
|
@ -125,23 +125,24 @@ $( function() {
|
|||
|
||||
<?php if ($type == 'is_audio'):?>
|
||||
<label for="pAudio"><?php echo i18n('Featured_Audio');?> <span class="required">*</span> (e.g Soundcloud)</label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postAudio)) { if (empty($postAudio)) { echo 'error';} } ?>" id="pAudio" name="audio"><?php if (isset($postAudio)) { echo $postAudio;} ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postAudio)) { if (empty($postAudio)) { echo 'error';} } ?>" id="pAudio" name="audio"><?php if (isset($postAudio)) { echo $postAudio;} ?></textarea>
|
||||
<input type="hidden" name="is_audio" value="is_audio">
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_video'):?>
|
||||
<label for="pVideo"><?php echo i18n('Featured_Video');?> <span class="required">*</span> (e.g Youtube)</label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postVideo)) { if (empty($postVideo)) { echo 'error';} } ?>" id="pVideo" name="video"><?php if (isset($postVideo)) { echo $postVideo;} ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postVideo)) { if (empty($postVideo)) { echo 'error';} } ?>" id="pVideo" name="video"><?php if (isset($postVideo)) { echo $postVideo;} ?></textarea>
|
||||
<input type="hidden" name="is_video" value="is_video">
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_image'):?>
|
||||
<label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';} } ?>" id="pImage" name="image"><?php if (isset($postImage)) { echo $postImage;} ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';} } ?>" id="pImage" name="image"><?php if (isset($postImage)) { echo $postImage;} ?></textarea>
|
||||
<input type="hidden" name="is_image" value="is_image">
|
||||
<br>
|
||||
<label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_quote'):?>
|
||||
|
|
@ -214,8 +215,38 @@ $( function() {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="insertMediaDialog" tabindex="-1" role="dialog" aria-labelledby="insertMediaDialogTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="insertMediaDialogTitle"><?php echo i18n('Insert_Image');?></h5>
|
||||
<button type="button" class="close" id="insertMediaDialogClose" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="insertMediaDialogURL">URL</label>
|
||||
<input type="text" class="form-control" id="insertMediaDialogURL" size="48" placeholder="<?php echo i18n('Enter_image_URL');?>" />
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
<label for="insertMediaDialogFile"><?php echo i18n('Upload');?></label>
|
||||
<input type="file" class="form-control-file" name="file" id="insertMediaDialogFile" accept="image/png,image/jpeg,image/gif" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="insertMediaDialogInsert"><?php echo i18n('Insert_Image');?></button>
|
||||
<button type="button" class="btn btn-secondary" id="insertMediaDialogCancel" data-dismiss="modal"><?php echo i18n('Cancel');?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Declare the base path. Important -->
|
||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>';</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||
|
|
|
|||
|
|
@ -179,23 +179,24 @@ $( function() {
|
|||
|
||||
<?php if ($type == 'is_audio'):?>
|
||||
<label for="pAudio"><?php echo i18n('Featured_Audio');?> <span class="required">*</span> (e.g Soundcloud)</label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postAudio)) { if (empty($postAudio)) { echo 'error';} } ?>" id="pAudio" name="audio"><?php echo $oldaudio; ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postAudio)) { if (empty($postAudio)) { echo 'error';} } ?>" id="pAudio" name="audio"><?php echo $oldaudio; ?></textarea>
|
||||
<input type="hidden" name="is_audio" value="is_audio">
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_video'):?>
|
||||
<label for="pVideo"><?php echo i18n('Featured_Video');?> <span class="required">*</span> (e.g Youtube)</label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postVideo)) { if (empty($postVideo)) { echo 'error';} } ?>" id="pVideo" name="video"><?php echo $oldvideo ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postVideo)) { if (empty($postVideo)) { echo 'error';} } ?>" id="pVideo" name="video"><?php echo $oldvideo ?></textarea>
|
||||
<input type="hidden" name="is_video" value="is_video">
|
||||
<br>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_image'):?>
|
||||
<label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label>
|
||||
<textarea rows="2" cols="20" class="form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';} } ?>" id="pImage" name="image"><?php echo $oldimage; ?></textarea>
|
||||
<textarea rows="2" cols="20" class="media-uploader form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';} } ?>" id="pImage" name="image"><?php echo $oldimage; ?></textarea>
|
||||
<input type="hidden" name="is_image" value="is_image">
|
||||
<br>
|
||||
<label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ($type == 'is_quote'):?>
|
||||
|
|
@ -273,7 +274,37 @@ $( function() {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="insertMediaDialog" tabindex="-1" role="dialog" aria-labelledby="insertMediaDialogTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="insertMediaDialogTitle"><?php echo i18n('Insert_Image');?></h5>
|
||||
<button type="button" class="close" id="insertMediaDialogClose" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="insertMediaDialogURL">URL</label>
|
||||
<input type="text" class="form-control" id="insertMediaDialogURL" size="48" placeholder="<?php echo i18n('Enter_image_URL');?>" />
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
<label for="insertMediaDialogFile"><?php echo i18n('Upload');?></label>
|
||||
<input type="file" class="form-control-file" name="file" id="insertMediaDialogFile" accept="image/png,image/jpeg,image/gif" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" id="insertMediaDialogInsert"><?php echo i18n('Insert_Image');?></button>
|
||||
<button type="button" class="btn btn-secondary" id="insertMediaDialogCancel" data-dismiss="modal"><?php echo i18n('Cancel');?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Declare the base path. Important -->
|
||||
<script type="text/javascript">var base_path = '<?php echo site_url() ?>';</script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/editor.js"></script>
|
||||
<script type="text/javascript" src="<?php echo site_url() ?>system/resources/js/media.uploader.js"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1628,7 +1628,8 @@ function has_prev($prev)
|
|||
'quote' => $prev->quote,
|
||||
'link' => $prev->link,
|
||||
'categoryUrl' => $prev->categoryUrl,
|
||||
'readTime' => $prev->readTime
|
||||
'readTime' => $prev->readTime,
|
||||
'readTime' => $prev->lastMod
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1660,7 +1661,8 @@ function has_next($next)
|
|||
'quote' => $next->quote,
|
||||
'link' => $next->link,
|
||||
'categoryUrl' => $next->categoryUrl,
|
||||
'readTime' => $next->readTime
|
||||
'readTime' => $next->readTime,
|
||||
'readTime' => $next->lastMod
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ if(PHP_VERSION_ID < 70300) {
|
|||
session_set_cookie_params(['samesite' => $samesite]);
|
||||
}
|
||||
|
||||
if (isset($_COOKIE['PHPSESSID']))
|
||||
session_start();
|
||||
session_start();
|
||||
|
||||
function login()
|
||||
{
|
||||
|
|
|
|||
62
system/resources/js/media.uploader.js
Normal file
62
system/resources/js/media.uploader.js
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
(function () {
|
||||
|
||||
//======Media Uploader=====
|
||||
|
||||
var dialogClose = function() {
|
||||
$('#insertMediaDialog').modal('hide');
|
||||
$('#insertMediaDialogURL').val('');
|
||||
$('#insertMediaDialogFile').val('');
|
||||
};
|
||||
$('#insertMediaDialogInsert').click( function() {
|
||||
$('.media-uploader').val('');
|
||||
$('.media-uploader').val( $('#insertMediaDialogURL').val().length > 0 ? $('#insertMediaDialogURL').val() : null );
|
||||
dialogClose();
|
||||
});
|
||||
$('#insertMediaDialogClose').click( function() {
|
||||
dialogClose();
|
||||
});
|
||||
$('#insertMediaDialogCancel').click( function() {
|
||||
dialogClose();
|
||||
});
|
||||
$('#insertMediaDialogFile').on('input', function(){
|
||||
var file = $("#insertMediaDialogFile").prop("files");
|
||||
var formData = new FormData();
|
||||
formData.append('file', file[0], file[0].name);
|
||||
// Set up the request.
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: base_path + 'upload.php',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function (response) {
|
||||
if (response.error == '0')
|
||||
{
|
||||
$('.media-uploader').val('');
|
||||
$('.media-uploader').val(base_path + response.path);
|
||||
dialogClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (response.error !== '') alert(response.error);
|
||||
else alert("An unknown error has occurred");
|
||||
console.error("Bad Response");
|
||||
console.error(response);
|
||||
$('#insertMediaDialogFile').val('');
|
||||
}
|
||||
},
|
||||
failure: function (response) {
|
||||
if (response.error !== '') alert(response.error);
|
||||
else alert("An unknown error has occurred");
|
||||
console.error("Unable to Upload");
|
||||
console.error(response);
|
||||
$('#insertMediaDialogFile').val('');
|
||||
}
|
||||
});//ajax
|
||||
});//oninput
|
||||
|
||||
$('#insertButton').click(function() {
|
||||
$('#insertMediaDialog').modal('show');
|
||||
});
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue