destoon调用供应产品图片的函数方法

分类栏目:destoon实战

127

$albums =  get_albums($item, 1);
<img src="http://www.dtmuban.com/course/{$albums[0]}" />

方法如下:

   function get_albums($item, $type = 0) {
       $imgs = array();
       if($item['thumb'] && !preg_match("/^[a-z0-9\-\.\:\/]{50,}$/i", $item['thumb'])) $item['thumb'] = '';
       if($item['thumb1'] && !preg_match("/^[a-z0-9\-\.\:\/]{50,}$/i", $item['thumb1'])) $item['thumb1'] = '';
       if($item['thumb2'] && !preg_match("/^[a-z0-9\-\.\:\/]{50,}$/i", $item['thumb2'])) $item['thumb2'] = '';
       if($type == 0) {
           $nopic = DT_SKIN.'image/nopic60.gif';
           $imgs[] = $item['thumb'] ? $item['thumb'] : $nopic;
           $imgs[] = $item['thumb1'] ? $item['thumb1'] : $nopic;
           $imgs[] = $item['thumb2'] ? $item['thumb2'] : $nopic;
       } else if($type == 1) {
           $nopic = DT_SKIN.'image/nopic240.gif';
           $imgs[] = $item['thumb'] ? str_replac('.thumb.', '.middle.', $item['thumb']) : $nopic;
           $imgs[] = $item['thumb1'] ? str_replac('.thumb.', '.middle.', $item['thumb1']) : $nopic;
           $imgs[] = $item['thumb2'] ? str_replac('.thumb.', '.middle.', $item['thumb2']) : $nopic;
       }
       return $imgs;
   }