코드이그나이터 기반 PHP 오픈소스 게시판 : 씨아이보드

일반페이지(document)에서 이미지맵 적용하기

  • 꽃이피는첫걸음
  • 0
  • 2,130
  • 글주소
  • 10-02

CI보드는 document의 에디터에서 이미지를 넣고 이미지맵을 등록하면 실제 보여지는 페이지에서 이미지맵이 작동하지 않습니다.

이는 이미지를 표시할때  get_view_thumbnail 이라는 함수로 이미지에 붙이는 속성들을 재구성 하기 때문입니다.


/application/helpers/basic_helper.php 의 955라인 get_view_thumbnail() 함수에 필요한 이미지 속성을 추가합니다.


$img = $matches[1][$i];

preg_match("/src=[\'\"]?([^>\'\"]+[^>\'\"]+)/i", $img, $m);

$src = isset($m[1]) ? $m[1] : '';

preg_match("/style=[\"\']?([^\"\'>]+)/i", $img, $m);

$style = isset($m[1]) ? $m[1] : '';

preg_match("/width:\s*(\d+)px/", $style, $m);

$width = isset($m[1]) ? $m[1] : '';

preg_match("/height:\s*(\d+)px/", $style, $m);

$height = isset($m[1]) ? $m[1] : '';

preg_match("/alt=[\"\']?([^\"\']*)[\"\']?/", $img, $m);

$alt = isset($m[1]) ? html_escape($m[1]) : '';

preg_match("/usemap=[\"\']?([^\"\']*)[\"\']?/", $img, $m);

$usemap = isset($m[1]) ? html_escape($m[1]) : '';

if (empty($width)) {

preg_match("/width=[\"\']?([^\"\']*)[\"\']?/", $img, $m);

$width = isset($m[1]) ? html_escape($m[1]) : '';

}

if (empty($height)) {

preg_match("/height=[\"\']?([^\"\']*)[\"\']?/", $img, $m);

$height = isset($m[1]) ? html_escape($m[1]) : '';

}


.......


if ($width) {

$thumb_tag .= ' width="' . $width . '" ';

}

$thumb_tag .= 'alt="' . $alt . '" usemap="'. $usemap.'" style="max-width:100%;"/>';


$img_tag = $matches[0][$i];

$contents = str_replace($img_tag, $thumb_tag, $contents);





이렇게 추가해 주면 이미지맵이 작동합니다.