Làm thế nào để Com K2 tự lấy ảnh trong bài ra làm đại diện, phần intro text bài viết nằm kế bên ảnh.Thanks all.
Tự code ^^ Mã: // Comment $text = $this->item->introtext; $searchTags = array( 'img' => '/<img[^>]+>/i', 'input' => '/<input[^>]+type\s?=\s?"image"[^>]+>/i' ); $searchSrc = '/src\s?=\s?"([^"]*)"/i'; $imagesintro = array(); foreach ($searchTags as $tag => $regex){ preg_match_all($regex, $text, $m); if (count($m)){ foreach ($m[0] as $htmltag){ preg_match_all($searchSrc, $htmltag, $msrc); if (count($msrc) && isset($msrc[1])){ foreach ($msrc[1] as $src){ array_push($imagesintro, $src); } } $text = str_replace($htmltag, '', $text); } } }