帝国cms/emcs的新闻系统模型中有一个不错的功能:
取第 张上传图为标题图片( 缩略图: 宽 *高 )
用起来很爽。
那么我们自己创建的模型怎样添加这个功能呢?
假设我们的模型里面有一个[图片集],叫做morepic
只需要去修改数据表中的这个字段,
把下面几行添加到“输入表单替换html代码“里面:
<!--提取第X张图片做为标题图片 && 标题图片为空的时候才会有效。开始!-->
<tr><td colspan=10>
取第
<input name="getfirsttitlepic" type="text" id="getfirsttitlepic" value="1" size="1">
张上传图为标题图片(
<input name="getfirsttitlespic" checked type="checkbox" id="getfirsttitlespic" value="1">
缩略图: 宽
<input name="getfirsttitlespicw" type="text" id="getfirsttitlespicw" size="3" value="<?=$public_r[spicwidth]?>">
*高
<input name="getfirsttitlespich" type="text" id="getfirsttitlespich" size="3" value="<?=$public_r[spicheight]?>">
)
</td></tr>
<!--提取第X张图片做为标题图片 && 标题图片为空的时候才会有效。结束!-->这样在添加信息的时候,就有这个功能了:
如果标题图片为空, 就会提取图片集的第一张图片,
根据需要生成或者不生成缩略图,然后自动保存为标题图片。