mirror of
https://github.com/go-gitea/gitea
synced 2024-11-21 23:51:32 +01:00
code optimization
This commit is contained in:
parent
651ee6030f
commit
19791a4cb8
2 changed files with 5 additions and 3 deletions
|
@ -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">
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue