ดึงเองเลยครับ
ผมให้ตัวอย่างโค้ดนะ เอาไป implement เอง หรือให้คนอื่นชว่ยทำนะครับ
<?php
// query for topic
$sql = '
SELECT t.id_topic,m.subject,m.posterName,m.posterTime,smf_boards.name
FROM smf_topics AS t
Inner Join smf_messages AS m ON (t.ID_FIRST_MSG = m.ID_MSG)
Left Join smf_boards ON (m.ID_BOARD = smf_boards.ID_BOARD)
WHERE t.id_board = '. $board_id .'
ORDER BY t.id_topic DESC
';
// query for attachment
$sql = "SELECT
m.ID_TOPIC as id_topic,
a.ID_ATTACH as id_attach
FROM smf_messages AS m Left Join smf_attachments AS a ON m.ID_MSG = a.ID_MSG
WHERE m.ID_TOPIC = '".$id_topic."' AND a.attachmentType = '0' ";
// image path (กรณีที่รูปเป็น attachment)
$img_path = '/forums/?action=dlattach;topic='.$id_topic.'.0;attach='.$rs['id_attach'].';image';
// image (กรณีที่หารูปจาก content body)
$sql = "SELECT m.ID_MSG, m.ID_TOPIC, m.body FROM smf_messages AS m WHERE m.id_topic='".$id_topic."'";
$result = mysql_query($sql);
while($rs = mysql_fetch_assoc($result)) {
$pattern = "/\[img\](.*?)\[\/img\]/is";
@preg_match_all($pattern, $rs['body'], $matches);
$img_path = '/?action=dlattach;topic='.$id_topic.'.0;attach='.$rs['id_attach'].';image';
if(count($matches[1]) > 0) {
foreach($matches[1] as $val) {
// image result $val;
echo '<pre>';
echo $val;
}
}
$doc=new DOMDocument();
$doc->loadHTML($rs['body']);
$xml=simplexml_import_dom($doc); // just to make xpath more simple
$images=$xml->xpath('//img');
foreach ($images as $img) {
// result $img['src']
echo '<pre>';
echo $img['src'];
}
}
?>