본문 바로가기

G5에서 video, embed, object 등 모든 미디어 허용하기

이온디 2017.10.31 00:05 조회 897 댓글 0
목록

htmlpurifier가 공식적으로 html5를 지원하지 않아 태그 허용할 경우 지원하지 않는 태그라고 오류를 출력합니다.

 

조만간 html5를 지원하겠지만, 현재는 아래처럼 설정해서 video 태그를 포함한 html5 태그를 정의하고 사용할 수 있도록 해주시면 됩니다.

 

html5 태그를 일일이 지정해 주면 다 사용할 수 있겠지만, 여기서는 미디어 관련 태그만 이야기 드립니다.

 

※  아미나빌더 1.4.7 버전 기준으로 /lib/common.lib.php 파일의 html_purifier() 함수 내의 내용을 아래처럼 변경해 줍니다.

 

$config->set('Attr.AllowedFrameTargets', array('_blank'));
$purifier = new HTMLPurifier($config);
return $purifier->purify($html);

위 부분을 찾아서 $purifier 윗줄에 아래 코드를 작성해주세요.

이렇게 수정해 주시면 iframe, video, embed, object, figure 등 다 글내용에서 사용이 가능합니다.

596라인부터 교체한다고 생각하시면 됩니다.

// HTML5 properties
   $config->set('HTML.DefinitionID', 'html5-definitions');
   $config->set('HTML.DefinitionRev', 1);
   if ($def = $config->maybeGetRawHTMLDefinition()) {
      $def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common');
      $def->addElement('figcaption', 'Inline', 'Flow', 'Common');
      $def->addElement('video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', array(
         'src' => 'URI',
         'type' => 'Text',
         'width' => 'Length',
         'height' => 'Length',
         'poster' => 'URI',
         'preload' => 'Enum#auto,metadata,none',
         'controls' => 'Bool',
      ));
      $def->addElement('source', 'Block', 'Flow', 'Common', array(
         'src' => 'URI',
         'type' => 'Text',
      ));
      $def->addAttribute('iframe', 'allowfullscreen', 'Bool');
   }
//여기까지



댓글 0

첫 댓글을 남겨보세요.

댓글을 작성하려면 로그인이 필요합니다.