Skip to content

Commit

Permalink
Fix dynamic avatar preview to account for kanboard/kanboard#4830
Browse files Browse the repository at this point in the history
  • Loading branch information
creecros committed Nov 6, 2022
1 parent 8ff9495 commit 68e8e7b
Show file tree
Hide file tree
Showing 5 changed files with 427 additions and 4 deletions.
18 changes: 16 additions & 2 deletions Assets/js/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ $(document).on('input', 'input[name="av_size"]', function(e) {
document.querySelector(".avatar-preview .avatar-letter").style.fontSize = (siz / 2) + "px";
} else {
var link = document.querySelector(".avatar-preview img").src;
var oldhash = link.substring(
link.indexOf("hash=") + 5,
link.lastIndexOf("&size=")
);
var path = document.getElementById("av_path").value;
var newhash = md5(path + siz);
var changedLink = link.substring(0, link.length-2);
document.querySelector(".avatar-preview img").src = changedLink + siz;
newchangedlink = changedLink.replace(oldhash, newhash);
document.querySelector(".avatar-preview img").src = newchangedlink + siz;
}
});

Expand All @@ -53,8 +60,15 @@ $(document).on('input', 'input[name="b_av_size"]', function(e) {
document.querySelector(".b-avatar-preview .avatar-letter").style.fontSize = (siz / 2) + "px";
} else {
var link = document.querySelector(".b-avatar-preview img").src;
var oldhash = link.substring(
link.indexOf("hash=") + 5,
link.lastIndexOf("&size=")
);
var path = document.getElementById("av_path").value;
var newhash = md5(path + siz);
var changedLink = link.substring(0, link.length-2);
document.querySelector(".b-avatar-preview img").src = changedLink + siz;
newchangedlink = changedLink.replace(oldhash, newhash);
document.querySelector(".b-avatar-preview img").src = newchangedlink + siz;
}
});

Expand Down
Loading

0 comments on commit 68e8e7b

Please sign in to comment.