Study ;3
Image Size 관련 ( chrome, IE )
유부뽀
2014. 7. 4. 12:15
바로 일전에 올린 이미지 미리보기와 연관되어 발생한 문제이다.
테스트는 chrome에서 이루어졌었는데 ie사용자도 고려해야하는 탓에 ie에서 테스트한 결과
뚜둔-_-이미지가 다 잘려서 나온다.
크롬에서는 this.width면 만사오케이였지만
IE에서는 this.width를 찾지 못하고 this.naturalWidth라는 값으로 넣어줘야했다.
이것도 9버전까지.
7,8버전은 naturalWidth라는 값도 없다! undefined!! ;ㅁ;
하는 수 없이 서버단에서 가져오기로 한다 ㅠㅠ
망할 IE. 뻑큐..ㅠㅠ
서버단에 함수를 만들고
public function getImgSize(){ $img_url = $this->post->img_url; $ret = getImageSize($img_url); if( $ret ){ echo json_encode(array('ret'=>'ok', 'width'=>$ret[0], 'height'=>$ret[1]) ); } else{ echo json_encode array( 'ret'=>'nok' ); } }
json으로 불러준다
... var img_url = 'test.jpg'; $.ajax({ type: 'POST', url : '/test/getImgSize', data: { 'img_url': img_url }, dataType: 'json', success: function(d){ if( d.ret == 'ok' ){ var img_width = d.width; var img_height = d.height; } ... }, error: function(d){ .. } });
반응형