반응형
Notice
Recent Posts
Recent Comments
Link
«   2023/09   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Archives
Today
Total
관리 메뉴

둘에서 하나로....

summernote 이미지 업로드시 폭 조절방법 본문

프로그래밍

summernote 이미지 업로드시 폭 조절방법

서기㏇ 2021. 9. 8. 13:59
반응형
        $('#summernote').summernote({height: 300,  focus:true,  maxWidth:500,  
            lang : 'ko-KR',

            callbacks: {
              onImageUpload: function(image) {
                 
                     var file = image[0];
                     var reader = new FileReader();
                    reader.onloadend = function() {
                        var image = $('<img>').attr('src',  reader.result);
                           image.attr('width','100%');
                        $('#summernote').summernote("insertNode", image[0]);
                    }
                   reader.readAsDataURL(file);
                
              }
          }

        
         });

위에서 중요한 부분은,
콜백함수로 받은 이미지에 폭을 100%로 지정하는 부분입니다.

이렇게 하시면 이미지 업로드시 폭 조절이 가능합니다. 

반응형
Comments