如题,帝国上传的图片会生成缩略图,但是没有标签进行调用,如果用图片剪切函数感觉又浪费资源了点,所有写了这个小函数。希望对大家有用。----菜鸟所做,高手就略过吧!
将虚线内的函数负责到 e/class/userfun.php ---------------------------------------------------- //返回大图片对应的缩略图( 大图路径) function user_Getsmallpic($file){ global $tranpicturetype; if(!$file) { return $file; } $filetype=GetFiletype($file); if(!strstr($tranpicturetype,','.$filetype.',')) { return $file; } $picname=GetFilename($file); $smallpic='small'.$picname; return str_replace("$picname","$smallpic","$file"); }
--------------------------------------------------- 调用的方法: 1:内容页调用 <img src="<?=user_Getsmallpic($navinfor[titlepic])?>" /> ---------------------------------- 2:列表页调用 (勾选 使用程序代码) $smallpic=user_Getsmallpic($r['titlepic']);
$listtemp=' <img src="'.$smallpic.'">
'; ------------------------------------ 3:灵动标签内调用
[e:loop={0,10,3,0}] <?php $smallpic=user_Getsmallpic($bqr['titlepic']);
?> <a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <img src="<?=$smallpic?>"/><br> [/e:loop]
|