开发者

Import urls from an xml file, cache the images

  1. I have a wordpress blog (this does not really matter i think).

  2. I have an xml file

  3. Doing a cron job every 5 minutes, I import the xml data inside a table

  4. On my wordpress blog I pull data from that table and display it

5. Problem is that i have abo开发者_JAVA技巧ut 20 images to display from 20 urls - this is slowing my site down

6. Is there a way to somehow cache the images and automatically refresh them every 5 minutes when the cron job acts?


would really need to see the structure of the xml, if you dont have curl you could use the more simpler file_get_contents(); / file_put_contents();

<?php 
//in your loop after you found or matched location and filename.
$img = file_get_contents('http://bla.com/imageLocation.jpg');
$newImageName='would_need_to_see_xml.jpg';
$newImagePath='./image_folder/';
file_put_contents($newImagePath.$newImageName,$img);
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜