카르마님의 lazyload 애드온 PHP8.0 호환방법 문의드립니다
CMS/프레임워크 | Rhymix 1.9 |
---|---|
개발 언어 | PHP 7.4 |
질문하기 전에 일단 구글링으로 스스로 해결해보는게 맞다고 생각해서 열심히 찾아보았는데, 아래코드에서 "create_function()" 함수 자체가 php8.0에서는 제거되어 에러가 발생하는 것 같습니다.
<?php
/**
* @ Lazyload addon
* @ author karma <soonj@nate.com>
* @ Using Vanilla JavaScript plugin for lazyloading images
* @ https://github.com/tuupola/jquery_lazyload/tree/2.x
*/
if(!defined("__XE__")) exit();
if(isCrawler()) return;
if($called_position != 'before_display_content' || Context::get('module') == 'admin') return;
if(!$addon_info->bgc) $addon_info->bgc = 'gray.png';
$GLOBALS['__LAZYLOAD__']['bgc'] = $addon_info->bgc ;
include_once("lazyload.lib.php");
$pattern_image_tag = "/<img(.*?)(src=\"[^\040]*)(.*)(files\/attach\/images\/[^\"]+)+([^>]*?)(>)+/i";
$pattern_documents_area = '/<!--Before(Document|Comment)\([0-9]+,[0-9]+\)-->(.*?)<!--After(Document|Comment)\([0-9]+,[0-9]+\)-->/is';
$output = preg_replace_callback($pattern_documents_area,create_function('$matches',"return preg_replace_callback('$pattern_image_tag', 'lazyloadImage', \$matches[0]);"), $output);
Context::loadFile(array('./addons/lazyload/lazyload.js','', '', null), true);
/**
* @ Lazyload addon
* @ author karma <soonj@nate.com>
* @ Using Vanilla JavaScript plugin for lazyloading images
* @ https://github.com/tuupola/jquery_lazyload/tree/2.x
*/
if(!defined("__XE__")) exit();
if(isCrawler()) return;
if($called_position != 'before_display_content' || Context::get('module') == 'admin') return;
if(!$addon_info->bgc) $addon_info->bgc = 'gray.png';
$GLOBALS['__LAZYLOAD__']['bgc'] = $addon_info->bgc ;
include_once("lazyload.lib.php");
$pattern_image_tag = "/<img(.*?)(src=\"[^\040]*)(.*)(files\/attach\/images\/[^\"]+)+([^>]*?)(>)+/i";
$pattern_documents_area = '/<!--Before(Document|Comment)\([0-9]+,[0-9]+\)-->(.*?)<!--After(Document|Comment)\([0-9]+,[0-9]+\)-->/is';
$output = preg_replace_callback($pattern_documents_area,create_function('$matches',"return preg_replace_callback('$pattern_image_tag', 'lazyloadImage', \$matches[0]);"), $output);
Context::loadFile(array('./addons/lazyload/lazyload.js','', '', null), true);
위에서 create_function 함수 구문을 어떻게 수정하면 php8.0에서도 작동하도록 대체가 가능할까요?!
댓글 2
라이믹스 저장소 이슈는 라이믹스 코어 관련 내용을 올리는 곳이지, 서드파티 자료 질문을 올리는 곳이 아닙니다.
즉 이슈 남기셔도 서드파티 문제이므로 바로 invalid 태그 붙고 close되지 답변이 돌아오지는 않을겁니다.