Home > Backend Development > PHP Tutorial > PHP Get remote pictures: Remote picture agent program_PHP tutorial

PHP Get remote pictures: Remote picture agent program_PHP tutorial

WBOY
Release: 2016-07-21 14:54:45
Original
1117 people have browsed it

Because most virtual hosts have traffic limits (especially blog hosts), many people choose to store pictures in free photo albums such as Flickr and Picasa, and then insert them into articles through external links. But since these websites are often blocked, I suggest that you try to put the pictures on your own server.

Since I am personally very lazy, if my blog is moved, too many article attachments will cause trouble in file migration. Therefore, I wrote a remote image proxy program based on cosbeta's Pika plug-in, and used Picasa, Flickr and PhotoBucket, three image hosting services used by many blogs, to prevent links from being reset. Please click here to download the script.

How to use

In fact, the principle of this script is the same as that of pika, but because I have made more modifications, the usage method will be different. Before using, please make sure you have a server that meets the requirements.

  • A foreign php host with large traffic
  • The server supports curl function

If the above requirements are met, then you can use this script.

First upload the script to the root directory of a subdomain name of the foreign host, and add the domain name that allows calling images to $allow_referer in the script, which must include the domain name where the script is located and where your blog is located Domain name, otherwise the image will not be displayed on your blog.

If the image you want to call is an image bed other than Picasa, Flickr and PhotoBucket, use the following code (yourdomain is the domain name where the script is located):

If you are calling a Picasa image, use the following code (image_url is the part after "ggpht.com/", lh* is the first section of the image external link address, which is the server number):

Calling images from Flickr and PhotoBucket is similar, just change the host parameter to farm* (Flickr) and i**** (PhotoBucket). The reason why the calling method of these image beds is so troublesome is that the risk of these image beds being blocked is relatively high. As long as these website domain names do not appear in the link when calling pictures from these websites, the pictures will be blocked. The link will not be reset, so visitors can still see the image when these websites are blocked.

After the image is called once through this script, it will be cached in the server. The second call will directly call the cache.

PS

I am making this script into a complete WordPress plugin, if you find any deficiencies in this script, please let me know.

Original link: http://blog.imbolo.com/php-get-image-from-remote-host/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364561.htmlTechArticleBecause most virtual hosts have traffic limits (especially blog hosts), many people choose to store pictures Go to free photo albums such as Flickr and Picasa, and then insert them into the text through external links...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template