Created
March 27, 2013 18:22
-
-
Save jbma/5256759 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//le chemin de l'image a ajouter | |
$image_path=''; | |
//le temps d'expiration' | |
$expire= time() - 360000; //valable 1 heure | |
//je vérifie que l'image existe et qu'elle n'est pas expirée | |
if (file_exists ($image_path) && filemtime($image_path) > $expire) | |
{ | |
//si elle existe je ne fais rien | |
} //fin if | |
//sinon je télécharge | |
else { | |
//je la télécharger et je l'assigne | |
$thumb= 'http://s.wordpress.com/mshots/v1/'.urlencode($url).'?w='.$width.'&h='.$height; | |
$get= file_get_contents($thumb); | |
file_put_contents($image_path, $get); | |
}//fin else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Merci pour ton aide ! :)
La fonction complète avec réécriture donc :
https://gist.github.com/siddartha/5270083