Commit ba9069c9 by sopham

default image

parent 5cb1cad4
Showing with 12 additions and 4 deletions
......@@ -95,7 +95,6 @@ $(document).ready(function() {
contentType: false,
processData: false,
success: function(data) {
console.log(data);
$('#imagePreview').css('background-image', 'url('+data +')');
$('#imagePreview').hide();
$('#imagePreview').fadeIn(650);
......@@ -103,14 +102,23 @@ $(document).ready(function() {
});
});
//display image when refresh
//display image when refresh, if there is no image display default image
$.ajax({
type: "POST",
url: "avatar-display.php",
success: function(data) {
var a = data;
$.ajax({
url: a,
type: 'HEAD',
error: function() {
$('#imagePreview').css('background-image', 'url(upload/default.png)');
},
success: function() {
$('#imagePreview').css('background-image', 'url('+ data +')');
}
});
}
});
});
......@@ -33,7 +33,7 @@ if(!isset($_SESSION['loggedin'])) {
<label for="imageUpload"></label>
</div>
<div class="avatar-preview">
<div id="imagePreview" style="background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/20625/avatar-bg.png);"></div>
<div id="imagePreview"></div>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment