kboard 미디어 업로드 이미지 리사이즈

https://www.cosmosfarm.com/threads/document/22058

위 게시물 참고하여 리사이즈 변경을 해봤는데 적용이 안되는데 확인 가능할까요?

 /wp-content/plugins/kboard/helper/Functions.helper.php 파일에 해당 함수

 

    $image_editor = wp_get_image_editor($upload_dir['basedir'] . "{$resize_dir}/{$basename}");
    if(!is_wp_error($image_editor)){
        $image_editor->resize($width, $height, true);
        $image_editor->save($new_image);
        return $new_image_src;

 

이부분을

 

    $image_editor = wp_get_image_editor($upload_dir['basedir'] . "{$resize_dir}/{$basename}");
    if(!is_wp_error($image_editor)){
        $image_editor->resize(800, $height, true);
        $image_editor->save($new_image);
        return $new_image_src;

으로 수정하면 이미지 고정비율이 800으로 되는줄 알았느데 적용이 안되네요.

어떻게 하면 이미지 리사이즈 비율을 바꿀수있을까요?

좋은 정보와 인맥을 동시에, 워드프레스 사용자 단톡방 참여하기
워드프레스 에러 기술지원 서비스 전문가에게 맡기세요
  • 안녕하세요~^^

    KBoard 플러그인에서 썸네일은 getThumbnail 함수를 사용해서 표시하고 있으며

    getThumbnail 함수 내부에서 kboard_resize 함수를 사용하고 있습니다.

    또, 게시글 본문의 이미지는 원본 이미지를 표시하고 있습니다.

    어느 부분의 이미지를 리사이즈하시려는 지도 알려주시겠어요?

    고맙습니다.

  • 제목에서와 같이

    kboard 미디어 업로드 <- 이미지 

    본문에 이미지 추가할때만 이기능이 사용되서요 ~ 또는 워드프레스 자체에디터가있지만 보안이 약해서 ㅠ

    게시글 본문의 이미지 리사이즈 함수위치를 알고 싶습니당.

  • 안녕하세요.

    KBoard 미디어 추가 기능으로 본문에 이미지를 삽입하면

    별도로 리사이즈하지 않고 원본 이미지를 그대로 표시하고 있습니다.

     

    본문 이미지 리사이즈 기능은

    추후 개선해서 업데이트하도록 하겠습니다.

    고맙습니다.

  • 이거 혹시 수정 되었나요?

    사용자가 게시판에 이미지를 올리면 4000x2000 픽셀정도인데

    이걸 500x250 정도로 줄여도 상관 없을 것같아서요.

  • 최신 버전의 KBoard 플러그인을 사용하시면

    이미지 최적화 기능을 사용하실 수 있습니다.

    워드프레스 관리자 -> KBoard -> 대시보드 페이지에서

    이미지 최적화 설정을 확인해보시겠어요?

    고맙습니다.

  • 답변 감사합니다!

    본문에 글을 올리면 사이즈 조정이 되네요!

    그런데 댓글로 글을 올리면 사이즈 조정이 되지 않아요 ㅠㅠ

    그리고 제가 글을 그냥 삭제하면 글에 등록된 이미지들도 다 삭제 되는 건가요?

    이미지 리스트는 어디서 확인 할 수 있을까요?

    여기에 계속 들을 작성하는게 맞는지 조금 고민되요. ^^;

     

     

  • 안녕하세요.

    새로운 질문이 아닌 이어지는 질문이라면

    해당 글의 댓글로 이어서 남겨주시면 저희가 확인해서 답변을 남기고 있습니다.

     

    댓글 쪽에도 이미지 최적화 기능을 적용하시려면

    KBoard 댓글 코어 쪽 파일을 수정해보시겠어요?

    FTP로 접속해서 /wp-content/plugins/kboard-comments/class/KBCommentController.class.php 파일에

    아래의 코드를 찾아서

    $upload_attach_files = array();
    if($upload_checker){
    	$upload_dir = wp_upload_dir();
    	$attach_store_path = str_replace($this->abspath, '', $upload_dir['basedir']) . "/kboard_attached/{$board->id}/" . date('Ym', current_time('timestamp')) . '/';
    	
    	$file = new KBFileHandler();
    	$file->setPath($attach_store_path);
    	
    	foreach($_FILES as $key=>$value){
    		if(strpos($key, $this->skin_attach_prefix) === false) continue;
    		$key = str_replace($this->skin_attach_prefix, '', $key);
    		$key = sanitize_key($key);
    		
    		$upload = $file->upload($this->skin_attach_prefix . $key);
    		$file_path = $upload['path'] . $upload['stored_name'];
    		$file_name = $upload['original_name'];
    		$metadata = $upload['metadata'];
    		
    		if($file_name){
    			$attach_file = new stdClass();
    			$attach_file->key = $key;
    			$attach_file->path = $file_path;
    			$attach_file->name = $file_name;
    			$attach_file->metadata = $metadata;
    			$upload_attach_files[] = $attach_file;
    		}
    	}
    }

    아래의 코드로 교체해보세요.

    $upload_attach_files = array();
    if($upload_checker){
    	$upload_dir = wp_upload_dir();
    	$attach_store_path = str_replace($this->abspath, '', $upload_dir['basedir']) . "/kboard_attached/{$board->id}/" . date('Ym', current_time('timestamp')) . '/';
    	
    	$file = new KBFileHandler();
    	$file->setPath($attach_store_path);
    	
    	foreach($_FILES as $key=>$value){
    		if(strpos($key, $this->skin_attach_prefix) === false) continue;
    		$key = str_replace($this->skin_attach_prefix, '', $key);
    		$key = sanitize_key($key);
    		
    		$upload = $file->upload($this->skin_attach_prefix . $key);
    		$file_path = $upload['path'] . $upload['stored_name'];
    		$file_name = $upload['original_name'];
    		$metadata = $upload['metadata'];
    		
    		if($file_name){
    			$filetype = wp_check_filetype($this->abspath . $file_path, array('jpg|jpeg|jpe'=>'image/jpeg', 'png'=>'image/png'));
    			
    			if(in_array($filetype['type'], array('image/jpeg', 'image/png'))){
    				$image_optimize_width = intval(get_option('kboard_image_optimize_width'));
    				$image_optimize_height = intval(get_option('kboard_image_optimize_height'));
    				$image_optimize_quality = intval(get_option('kboard_image_optimize_quality'));
    				
    				$image_editor = wp_get_image_editor($this->abspath . $file_path);
    				if(!is_wp_error($image_editor)){
    					$is_save = false;
    					
    					if($image_optimize_width && $image_optimize_height){
    						$image_editor->resize($image_optimize_width, $image_optimize_height);
    						$is_save = true;
    					}
    					if(0 < $image_optimize_quality && $image_optimize_quality < 100){
    						$image_editor->set_quality($image_optimize_quality);
    						$is_save = true;
    					}
    					if($is_save){
    						$image_editor->save($this->abspath . $file_path);
    					}
    				}
    			}
    			
    			$attach_file = new stdClass();
    			$attach_file->key = $key;
    			$attach_file->path = $file_path;
    			$attach_file->name = $file_name;
    			$attach_file->metadata = $metadata;
    			$upload_attach_files[] = $attach_file;
    		}
    	}
    }

    해당 코드 변경 사항은 아래 링크에서도 확인 가능합니다.

    https://github.com/cosmosfarm/KBoard-wordpress-plugin/commit/f0a5ab30f611ac27548d5706228614ae0e6d13f2

    추후 업데이트에 반영하도록 하겠습니다.

     

    KBoard 게시글 삭제 시 첨부파일도 모두 삭제됩니다.

    이미지 리스트는 따로 지원하지 않고 있습니다.

     

     

    KBoard 플러그인의 첨부파일은

    FTP로 접속해서 /wp-content/uploads/kboard_attached 경로에 저장되며

    썸네일은 /wp-content/uploads/kboard_thumbnails 경로에 저장됩니다.

    고맙습니다.

  • 항상 친절한 답변감사합니다.

    새해엔 더 행복하세요!

  • I suggest to use these sites to resize and compress the images :

    Image Resizer 

    Jpeg Compress

워드프레스 에러 기술지원 서비스 전문가에게 맡기세요