website construction

Jinan website construction_dedecms calls pictures in custom fields

A few days ago, I built a website and found that although three pages for one question are the same except for different image sizes, if there are two pages, we all understand that a thumbnail […]

article directories

A few days ago, I built a website and found that although three pages for a question are the same except for different image sizes, if there are two pages, we all understand that one thumbnail image and one picture is hung in one content. This way, we can make two pictures of different image sizes quickly and smoothly, but what to do with the three, so we thought of custom fields.

Open the/include/extend.function.php file (Note: This file is a custom function interface file reserved by the system and is mainly used for secondary development. If you are an older version, you don't have this file by default, just create your own PHP file), at the bottom?> Add the following function code to the previous line

function GetOneImgUrl($img,$ftype=1){
if($img <> ”){
$dtp = new DedeTagParse();
$dtp->LoadSource($img);
if(is_array($dtp->CTags)){
foreach($dtp->CTags as $ctag){
if($ctag->GetName()==’img’){
$width = $ctag->GetAtt(‘width’);
$height = $ctag->GetAtt(‘height’);
$imgurl = trim($ctag->GetInnerText());
$img = ”;
if($imgurl !=”){
if($ftype==1){
$img .= $imgurl;
}
else{
$img .=‘<img src=”‘.$ imgurl.”’width=”‘.$ width.”’height=”‘.$ height.”’/>’;
}
}
}
}
}
$dtp->Clear();
return $img;
}
}
The function ends here.,...
———————————–
{dede:arclist row=’5′ orderby=’id’ channelid=’1′ addfields=’imgurl’}
<li>[field:title/][field:imgurl function=’GetOneImgUrl(@me,0)’/]</li>
{/dede:arclist}
Here is an explanation of this code... addfields =‘imgurl’ ? imgurl is the name of your custom field
[field:imgurl function='GetOneImgUrl(@me,0)'/] This is the address in the custom image
If you don't know what you can do, you can ask me for help.
above isseoDetailed introduction to the pictures in the custom fields of dedecms call