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