WP相关文章插件修改成批量添加自定义图片地址_PHP
WordPress 相关日志插件:WordPress Related Posts,这个也是由水煮鱼制作的插件,其中有一项功能可以通过自定义字段显示缩略图,对于一个新博客而言,可以慢慢添加,但是对于一个已经有几百上千的日志,如果确实需要相关日志只显示图片而不需要使用标题的类型,这个时候你去自定字段一个个修改,耗时不说,累都累死了。我想到了修改,经过在源码的基础上修改后,适用一切正常,至于漂亮与否,还需要各位自己修改了,毕竟修改PHP并且要设计的好看。
修改的主要作用是在大量文章需要设置自定义字段来达到相关日志显示缩略图时,可以使用我修改过的代码,为设置您的每篇文章的第一张图片规律性的替换,比如规律性的替换.jpg 为 _s.jpg
不仅适用于flickr,一些大型网站也是比较适合的,wordpress的自带图片库也可以适用,但是具体怎么替换后缀名需要你自己手动修改下代码。
注意:
只是一些小的改动,插件源码来自于水煮鱼
插件设置不需要勾选Related Posts with Thumbnail
下载地址:相关日志只显示缩略图插件:http://www.yisougou.com/download/relatedpost-only-display-first-images.rar
哪些地方你可能需要改动:
$content = $related_post-> post_content;
preg_match_all('||i', $related_post->post_content, $matches);
$img_src = $matches[1][0]; //first photo
if (eregi("flickr.com",$img_src)){
$img_url = str_replace(".jpg", "_s.jpg", $img_src);
}else{
$img_url=$img_src;
}
以上你可以设置怎么替换图片后缀,以上只抓取每篇文章的第一张图片。
和
以上你可以设置图片显示格式,有漂亮的格式教我。
效果参考地址:http://www.babyshoot.cn/2010/01/22/dreaming-of-forever.html
这样一来,就不需要每篇文章都去修改添加自定义字段的缩略图图片地址了。
源码来源于:http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.
