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.