Extra Form
PHP PHP 7.4
CMS Rhymix 2.1

안녕하세요.

 

타운에 공개할 애드온을 하나 작업 하고 있습니다.

댓글에 이미지가 100%로 들어가서 보기가 안좋아서

 

댓글 이미지 리사이징 애드온을 만들고 있습니다.

이론상 css로 처리가 가능할 것 같아 애드온에 그냥 넣어주려고합니다.

 

실제로

[class*="comment_"] p img{
    max-width: 500px !important;
}

이렇게만 해줘도 보기가 훨씬 좋네요.

 

 

애드온화 하기위해서

 

Context::addCssFile(__DIR__ . '/width.css');
width.css 파일 안에 php 변수값불러오기를 1차로 시도해봤습니다.

 

[class*="comment_"] p img{
    max-width: <?php echo $max_width_size; ?>px !important;
}

 

역시나 확장자가 .css 이다보니 안되더라구요.

 

2차로

 

애드온 파일에 아래처럼 style 값을 강제로 echo 로 출력해 보았습니다.

        $css_width = $addon_info->max_width_size;
        //Context::addCssFile(__DIR__ . '/width.css');
        echo '<style>[class*="comment_"] p img { max-width: ' . $max_width_size . ' !important; }</style>';

 

이렇게해도 에러가 발생하네요.

 

애드온에서 변수값(max_width_size)의 css를 불러오는 좋은 방법이 있을까요?

 

제가 넣고 싶은 css는 아래와 같습니다.

[class*="comment_"] p img{
    max-width: <?php echo $max_width_size; ?>px !important;
}

  • profile
    Context::addHtmlHeader('<style>[class*="comment_"] p img { max-width: ' . $max_width_size . ' !important; }</style>');

    addHtmlHeader 함수로 head 태그 부분에 html을 추가할수 있습니다. 위 코드처럼 해보시겠어요?

  • profile profile
    와 ㅎㅎㅎ 감사합니다.
    한방에 해결 되었습니다.
  • profile profile
    https://xetown.com/download/1752082
    덕분에 잘 적용하여 공개하였습니다.