Solve the problem of calling Dede custom picture fields

Article Introduction

I encountered such a problem in the process of making a website, and I found a solution. Collect and share: Why is the picture field called from the custom list on the home page not the correct picture address, but similar to: quote
{dede:img text='' width= '270' height='129'} /uploads/101017/1-10101H21F54P.gif {/dede:img}

Such a format!
Obviously, this cannot be displayed correctly, which is caused by the processing method of the dream weaving custom picture field. To solve this problem, we must create a custom function, which is implemented as:

1. Implementation method 1) Create a custom function and
open the /include/extend.func.php file (Note: This file is a custom function interface file reserved by the system, which is mainly used for secondary development. If you are an old version , There is no such file by default, just create a PHP file by yourself), add the following function code in the bottom?>previous line:

Fold PHP code to copy content to clipboard

Quote

function GetOneImgUrl( i m g , img, img,ftype=1){
if($img <> ‘’){
$dtp = new DedeTagParse();
d t p − > L o a d S o u r c e ( dtp->LoadSource( d t p ->LoadSource(img);
if(is_array(KaTeX parse error: Expected '}', got 'EOF' at end of input: … foreach(dtp->CTags as KaTeX parse error: Expected '}', got 'EOF' at end of input: … if(ctag->GetName()‘img’){
$width = $ctag->GetAtt(‘width’);
$height = $ctag->GetAtt(‘height’);
i m g u r l = t r i m ( imgurl = trim( imgurl=trim(ctag->GetInnerText());
i m g = ′ ′ ; i f ( img = ''; if( img=;if(imgurl != ‘’){
if($ftype
1){
$img .= $imgurl;
}
else{
$img .=
}
}

            }  
        }  
    }  
    $dtp->Clear();  
    return $img;      
}  

}

Save it and close it.

2) Function call method
Q: After we create a function, how to call this function?

Answer: The calling method of this function is:

[field: custom picture field name function="GetOneImgUrl(@me,display type)"/]

For example, if our custom image field is named imgurl, there are two ways to call:

引用
[field:imgurl function=‘GetOneImgUrl(@me,0)’/]
[field:imgurl function=‘GetOneImgUrl(@me,1)’/]

Guess you like

Origin blog.csdn.net/a9490489/article/details/108596457