Skip to content

Commit

Permalink
feat: 이미지 업로드 시 최적화 옵션 추가
Browse files Browse the repository at this point in the history
이미지 업로드 패널에서 "이미지 최적화" 체크박스를 추가하여 이미지 파일 업로드 시 설정 값을 함께 전송하도록 함.
  • Loading branch information
kkigomi authored and onedark23 committed Aug 12, 2024
1 parent dda8d0d commit ac5e849
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugins/dialog/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
sizeUnit: options._imageSizeUnit,
_linkElement: '',
_altText: '',
_optimize: true,
_align: 'none',
_floatClassRegExp: '__se__float\\-[a-z]+',
_v_src: {_linkValue: ''},
Expand Down Expand Up @@ -71,6 +72,7 @@ export default {
contextImage.imgUrlFile = image_dialog.querySelector('._se_image_url');
contextImage.focusElement = contextImage.imgInputFile || contextImage.imgUrlFile;
contextImage.altText = image_dialog.querySelector('._se_image_alt');
contextImage.optimize = image_dialog.querySelector('._se_image_check_optimize');
contextImage.captionCheckEl = image_dialog.querySelector('._se_image_check_caption');
contextImage.previewSrc = image_dialog.querySelector('._se_tab_content_image .se-link-preview');

Expand Down Expand Up @@ -197,6 +199,7 @@ export default {
html += '' +
'<div class="se-dialog-form se-dialog-form-footer">' +
'<label><input type="checkbox" class="se-dialog-btn-check _se_image_check_caption" />&nbsp;' + lang.dialogBox.caption + '</label>' +
'<label><input type="checkbox" checked class="se-dialog-btn-check _se_image_check_optimize" />&nbsp;이미지 최적화</label>' +
'</div>' +
'</div>' +
'</div>' +
Expand Down Expand Up @@ -366,6 +369,7 @@ export default {
e.stopPropagation();

contextImage._altText = contextImage.altText.value;
contextImage._optimize = contextImage.optimize.checked;
contextImage._align = contextImage.modal.querySelector('input[name="suneditor_image_radio"]:checked').value;
contextImage._captionChecked = contextImage.captionCheckEl.checked;
if (contextImage._resizing) contextImage._proportionChecked = contextImage.proportion.checked;
Expand Down Expand Up @@ -480,9 +484,13 @@ export default {
// server upload
if (typeof imageUploadUrl === 'string' && imageUploadUrl.length > 0) {
const formData = new FormData();
const contextImage = this.context.image;
for (let i = 0; i < filesLen; i++) {
formData.append('file-' + i, files[i]);
}

formData.append('optimize', contextImage._optimize);

this.plugins.fileManager.upload.call(this, imageUploadUrl, this.options.imageUploadHeader, formData, this.plugins.image.callBack_imgUpload.bind(this, info), this.functions.onImageUploadError);
} else { // base64
this.plugins.image.setup_reader.call(this, files, info.anchor, info.inputWidth, info.inputHeight, info.align, info.alt, filesLen, info.isUpdate);
Expand Down Expand Up @@ -1119,6 +1127,7 @@ export default {
}

contextImage.altText.value = '';
contextImage.optimize.checked = true;
contextImage.modal.querySelector('input[name="suneditor_image_radio"][value="none"]').checked = true;
contextImage.captionCheckEl.checked = false;
contextImage._element = null;
Expand Down

0 comments on commit ac5e849

Please sign in to comment.