0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-21 18:22:13 +01:00

code optimization

This commit is contained in:
Kerwin Bryant 2024-11-20 13:52:43 +00:00
parent 651ee6030f
commit 19791a4cb8
2 changed files with 5 additions and 3 deletions

View file

@ -131,7 +131,7 @@
<div class="cropper-preview">
<h3>{{ctx.Locale.Tr "preview"}}</h3>
<div>
<img id="cropper-result">
<img id="cropper-result" class="ui avatar tw-align-middle">
</div>
</div>
<div class="cropper-editor">

View file

@ -15,6 +15,7 @@ export function initCompCropper() {
const done = function (url) {
source.src = url;
result.src = url;
if (cropper) {
cropper.replace(url);
@ -22,11 +23,12 @@ export function initCompCropper() {
cropper = new Cropper(source, {
aspectRatio: 1,
viewMode: 1,
autoCrop: false,
crop() {
const canvas = cropper.getCroppedCanvas();
result.src = canvas.toDataURL();
result.src = canvas.toDataURL(); //The default format type is image/png.
canvas.toBlob((blob) => {
const file = new File([blob], filename, {type: 'image/jpeg', lastModified: Date.now()});
const file = new File([blob], filename, {type: 'image/png', lastModified: Date.now()});
const container = new DataTransfer();
container.items.add(file);
input.files = container.files;