phpcms v9 調用自訂欄位多圖片的第一張或第N張圖為縮圖

來源:互聯網
上載者:User

標籤:style   blog   color   os   使用   sp   檔案   div   on   

1.開啟相應要使用組圖的模型的組圖欄位,添加組圖 欄位提示為

1 <div class="content_attr"> 2 <label><input type=‘checkbox‘ name=‘auto_thumbp‘ value="1" checked>是否擷取內容第</label><input type="text" name="auto_thumb_nop" value="1" size="2" class="">張圖片作為標題圖片 3 </div> 

2.開啟phpcms\model\content_model.class.php 找到如下內容

1 //自動提取縮圖 2 if(isset($_POST[‘auto_thumb‘]) && $systeminfo[‘thumb‘] == ‘‘ && isset($modelinfo[‘content‘])) { 3  $content = $content ? $content : stripslashes($modelinfo[‘content‘]); 4  $auto_thumb_no = intval($_POST[‘auto_thumb_no‘])-1; 5  if(preg_match_all("/(src)=([\"|‘]?)([^ \"‘>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) { 6   $systeminfo[‘thumb‘] = $matches[3][$auto_thumb_no]; 7  } 8 } 

在這下面添加如下代碼

1 //自動提取組圖為縮圖 2 if(isset($_POST[‘auto_thumbp‘]) && $systeminfo[‘thumb‘] == ‘‘ && isset($modelinfo[‘content‘])) {   3  $自訂欄位名 = $自訂欄位名 ? $自訂欄位名 : stripslashes($modelinfo[‘自訂欄位名‘]); 4  $auto_thumb_no = intval($_POST[‘auto_thumb_nop‘])-1; 5  if(preg_match_all("/(=>)\s([\b\"|‘]?)([^ \"‘>]+\.(gif|jpg|jpeg|bmp|png))\\2/i", $自訂欄位名, $matches)) { 6   $systeminfo[‘thumb‘] = $matches[3][$auto_thumb_no]; 7  } 8 } 

注意:content_model.class.php檔案有兩片需要添加這個代碼,一處是新增加文章的時候,一處是修改文章的時候!

phpcms v9 調用自訂欄位多圖片的第一張或第N張圖為縮圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.