WordPress Article Picture Property substitution

Source: Internet
Author: User
Recently with WordPress built a small picture station, a little question to ask under:

Article page code:








Question 1, there are spaces in the picture path, how to use PHP to replace all spaces with "-", from 1112 cat into 1112-cat
Issue 2, after replacing a space, in the picture path. jpg followed by seven bull picture style!width300

Ask these two questions how to use PHP to solve

Reply content:

Recently with WordPress built a small picture station, a little question to ask under:

Article page code:








Question 1, there are spaces in the picture path, how to use PHP to replace all spaces with "-", from 1112 cat into 1112-cat
Issue 2, after replacing a space, in the picture path. jpg followed by seven bull picture style!width300

Ask these two questions how to use PHP to solve

Picture Station picture is a local upload or crawl of the picture? The last image is uploaded to seven kn? After uploading or crawling, just follow the instructions you have replaced, followed by the parameters you mentioned.

I don't know if I didn't understand your difficulty. can continue to reply to ask, follow up my computer to update your reply.

    1. Question 1

A reminder, even if you use PHP to replace the space, but if the directory name on your server is not modified, your picture can only be opened to 404.
PHP functions, you can use Str_replace, this function in my Site history article has been applied, you can search for str_replace in the text, see the second result.

    1. Question 2

You can refer to this:

/** * 七牛缩略图和水印**/function QiNiuThumbnailWatermark($content) {   global $post;   $pattern ="//i";   /* 下面这行代码中的dengxiang是七牛样式中的样式名称,而斜杠为七牛中设置的样式分割符 */   $replacement = '';   $content = preg_replace($pattern, $replacement, $content);   return $content;}add_filter('the_content', 'QiNiuThumbnailWatermark');?>

The specific use of the method can be seen here: seven the correct way to use the image processing style

  • Related 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.