Import urls from an xml file, cache the images
I have a wordpress blog (this does not really matter i think).
I have an xml file
Doing a cron job every 5 minutes, I import the xml data inside a table
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);
?>
精彩评论