首页 >php教程 >PHP源码 >读取图片地址

读取图片地址

PHP中文网
PHP中文网原创
2016-05-25 17:08:05954浏览

代码

<?php
function litimgurls($imgid=0)
{
    global $lit_imglist,$dsql;
    //获取附加表
    $row = $dsql->GetOne("SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c 
                                                            ON a.channel=c.id where a.id=&#39;$imgid&#39;");
    $addtable = trim($row[&#39;addtable&#39;]);
    
    //获取图片附加表imgurls字段内容进行处理
    $row = $dsql->GetOne("Select imgurls From `$addtable` where aid=&#39;$imgid&#39;");
    
    //调用inc_channel_unit.php中ChannelUnit类
    $ChannelUnit = new ChannelUnit(2,$imgid);
    
    //调用ChannelUnit类中GetlitImgLinks方法处理缩略图
    $lit_imglist = $ChannelUnit->GetlitImgLinks($row[&#39;imgurls&#39;]);
    
    //返回结果
    return $lit_imglist;
}

/****************  
  function GetOneImgUrl  
  @@ 功能:读取自定义字段图片地址  
*****************/  
  
function GetOneImgUrl($img,$ftype=1){   
    echo $img;
    if($img <> &#39;&#39;){   
        $dtp = new DedeTagParse();   
        $dtp->LoadSource($img);   
        if(is_array($dtp->CTags)){   
            foreach($dtp->CTags as $ctag){   
                if($ctag->GetName()==&#39;img&#39;){   
                    $width = $ctag->GetAtt(&#39;width&#39;);   
                    $height = $ctag->GetAtt(&#39;height&#39;);   
                    $imgurl = trim($ctag->GetInnerText());   
                    $img = &#39;&#39;;   
                    if($imgurl != &#39;&#39;){   
                        if($ftype==1){   
                            $img .= $imgurl;   
                        }   
                        else{   
                            $img .= &#39;<img src="&#39;.$imgurl.&#39;" width="&#39;.$width.&#39;" height="&#39;.$height.&#39;" />&#39;;   
                        }   
                    }   
                               
                }   
            }   
        }   
        $dtp->Clear();   
        return $img;       
    }   
}  


/*根据文章id 返回文章arcurl
        *$ID 文章id
        */
        function getArcurlByArcid($ID)  
        {  
            global $dsql;  
            $query = "Select arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.moresite,tp.siteurl,tp.sitepath from dede_archives arc left join dede_arctype tp on arc.typeid=tp.id where arc.id = ".$ID;  
            $row = $dsql->GetOne($query);  
            $ReturnURL = GetFileUrl($row[&#39;id&#39;],$row[&#39;typeid&#39;],$row[&#39;senddate&#39;],$row[&#39;title&#39;],$row[&#39;ismake&#39;],  
            $row[&#39;arcrank&#39;],$row[&#39;namerule&#39;],$row[&#39;typedir&#39;],$row[&#39;money&#39;],$row[&#39;filename&#39;],$row[&#39;moresite&#39;],$row[&#39;siteurl&#39;],$row[&#39;sitepath&#39;]);  
            return $ReturnURL;  
        }
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn