Dede retrieves the first image of the article.

Source: Internet
Author: User
Tags preg

Dede calls the implementation method of the first image (non-thumbnail) in the document

This article mainly introduces the implementation code of Dede calling the first image in the article. For more information, see

The first step is to modify the include/extend. func. php file and insert a function at the bottom to query the additional table of the Article. to query the image set or something, change the table name.

Copy code

The Code is as follows:

Function getfirstimg ($ arcid) {Global $ dsql; $ query = "select body from 'dede _ addonarticle' where aid = '$ arcid '"; $ ROW = $ dsql-> getone ($ query); $ preg = "/ /I "; preg_match_all ($ preg, $ row ['body'], $ match); // print_r ($ match); return $ match [1] [0];}

The second part is to modify the call label include/taglib/arclist. lib. the litpic field is required when PHP dream calls the content of the article. You need to reconstruct this field and find $ row [litpic] In the function lib_arclistdone (). add // call the first image of the article, which is not a thumbnail. If it is null, the thumbnail is called.

Copy code

The Code is as follows:

If (getfirstimg ($ row ['id'])! = "") {$ Row ['firstimg '] = getfirstimg ($ row ['id']);}

The write judge is to call the article without a graph, you can still select the thumbnail display. Zhimeng v57 SP1 contains approximately 475 rows, and can be added under the $ row [] array. In this way, you can use the original tag field to call the image. The first image in the article shows the first image. If no image is displayed, the thumbnail of the article is called.

 

Dede retrieves the first image of the article.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.