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

读取图片地址

PHP中文网
Release: 2016-05-25 17:08:05
Original
949 people have browsed it

代码

<?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;  
        }
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template