【phpcms-v9】phpcms-v9中添加内容时自动提取缩略图
发布:smiling 来源: PHP粉丝网 添加日期:2014-10-24 10:58:42 浏览: 评论:0
1.代码如下:
- //自动提取摘要
- if(isset($_POST['add_introduce']) && $systeminfo['description'] == '' && isset($modelinfo['content'])) {
- $content = stripslashes($modelinfo['content']);
- $introcude_length = intval($_POST['introcude_length']);
- $systeminfo['description'] = str_cut(str_replace(array("\r\n","\t",'[page]','[/page]','“','”',' '), '', strip_tags($content)),$introcude_length);
- $inputinfo['system']['description'] = $systeminfo['description'] = addslashes($systeminfo['description']);
- }
- //自动提取缩略图
- if(isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
- $content = $content ? $content : stripslashes($modelinfo['content']);
- $auto_thumb_no = intval($_POST['auto_thumb_no'])-1;
- if(preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
- $systeminfo['thumb'] = $matches[3][$auto_thumb_no];
- }
- }
2.案例:
- <?php
- $str='<a href="http://www.phpfensi.com/"><img src="http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg"></a><a href="http://www.baidu.com/"><img src="http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg"></a>';
- preg_match_all("/(src)=([\"|']?)([^ \"'>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $str, $out);
- echo "<pre>";
- print_r($out);
- ?>
3.结果:
- <pre>Array
- (
- [0] => Array
- (
- [0] => src="http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg"
- [1] => src="http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg"
- )
- [1] => Array
- (
- [0] => src
- [1] => src
- )
- [2] => Array
- (
- [0] => "
- [1] => "
- )
- [3] => Array
- (
- [0] => http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg
- [1] => http://www.phpfensi.com/uploadfile/2012/1205/20121205112558940.jpg
- )
- [4] => Array
- (
- [0] => jpg
- [1] => jpg
- )
- )
Tags: phpcms提取缩略图 phpcms添加内容
相关文章
- ·PHPCMS V9添加内容时JS代码直接显示的解决办法?(2014-10-22)
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)