Browse Source

Add image preview

pull/663/head
danpros 2 years ago
parent
commit
4d2b505b56
3 changed files with 16 additions and 8 deletions
  1. +6
    -4
      system/admin/views/add-content.html.php
  2. +5
    -3
      system/admin/views/edit-content.html.php
  3. +5
    -1
      system/resources/js/media.uploader.js

+ 6
- 4
system/admin/views/add-content.html.php View File

@ -138,8 +138,10 @@ $( function() {
<?php endif;?> <?php endif;?>
<?php if ($type == 'is_image'):?> <?php if ($type == 'is_image'):?>
<style>.imgPrev img {width:60%;} </style>
<label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label> <label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label>
<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>
<div class="imgPrev card"><?php if (isset($postImage)) { echo '<img id="imgFile" src="' . $postImage . '"/>';} ?></div>
<input type="text" style="display:none" class="media-uploader form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';}} ?>" id="pImage" name="image" readonly value="<?php if (isset($postImage)) { echo $postImage;} ?>">
<input type="hidden" name="is_image" value="is_image"> <input type="hidden" name="is_image" value="is_image">
<br> <br>
<label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label> <label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label>
@ -215,7 +217,7 @@ $( function() {
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="insertMediaDialog" tabindex="-1" role="dialog" aria-labelledby="insertMediaDialogTitle" aria-hidden="true"> <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-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
@ -242,8 +244,8 @@ $( function() {
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div> </div>
<!-- Declare the base path. Important --> <!-- Declare the base path. Important -->


+ 5
- 3
system/admin/views/edit-content.html.php View File

@ -192,8 +192,10 @@ $( function() {
<?php endif;?> <?php endif;?>
<?php if ($type == 'is_image'):?> <?php if ($type == 'is_image'):?>
<style>.imgPrev img {width:60%;} </style>
<label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label> <label for="pImage"><?php echo i18n('Featured_Image');?> <span class="required">*</span></label>
<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>
<div class="imgPrev"><img id="imgFile" src="<?php echo $oldimage; ?>"/></div>
<input style="display:none" type="text" class="media-uploader form-control text <?php if (isset($postImage)) { if (empty($postImage)) { echo 'error';}} ?>" id="pImage" name="image" readonly value="<?php echo $oldimage; ?>">
<input type="hidden" name="is_image" value="is_image"> <input type="hidden" name="is_image" value="is_image">
<br> <br>
<label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label> <label class="btn btn-primary btn-sm" id="insertButton"><?php echo i18n('Insert_Image');?></label>
@ -274,7 +276,7 @@ $( function() {
</div> </div>
</div> </div>
</div> </div>
<div class="modal fade" id="insertMediaDialog" tabindex="-1" role="dialog" aria-labelledby="insertMediaDialogTitle" aria-hidden="true"> <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-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
@ -301,7 +303,7 @@ $( function() {
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div> </div>
<!-- Declare the base path. Important --> <!-- Declare the base path. Important -->
<script type="text/javascript">var base_path = '<?php echo site_url() ?>';</script> <script type="text/javascript">var base_path = '<?php echo site_url() ?>';</script>


+ 5
- 1
system/resources/js/media.uploader.js View File

@ -9,7 +9,9 @@
}; };
$('#insertMediaDialogInsert').click( function() { $('#insertMediaDialogInsert').click( function() {
$('.media-uploader').val(''); $('.media-uploader').val('');
$('.imgPrev > img').remove();
$('.media-uploader').val( $('#insertMediaDialogURL').val().length > 0 ? $('#insertMediaDialogURL').val() : null ); $('.media-uploader').val( $('#insertMediaDialogURL').val().length > 0 ? $('#insertMediaDialogURL').val() : null );
$('.imgPrev').prepend($('<img>',{id:'imgFile',src: $('#insertMediaDialogURL').val()}));
dialogClose(); dialogClose();
}); });
$('#insertMediaDialogClose').click( function() { $('#insertMediaDialogClose').click( function() {
@ -33,7 +35,9 @@
if (response.error == '0') if (response.error == '0')
{ {
$('.media-uploader').val(''); $('.media-uploader').val('');
$('.imgPrev > img').remove();
$('.media-uploader').val(base_path + response.path); $('.media-uploader').val(base_path + response.path);
$('.imgPrev').prepend($('<img>',{id:'imgFile',src: base_path + response.path}));
dialogClose(); dialogClose();
} }
else else
@ -54,7 +58,7 @@
} }
});//ajax });//ajax
});//oninput });//oninput
$('#insertButton').click(function() { $('#insertButton').click(function() {
$('#insertMediaDialog').modal('show'); $('#insertMediaDialog').modal('show');
}); });


Loading…
Cancel
Save