Skip to content

Instantly share code, notes, and snippets.

@jbma
Created March 27, 2013 18:22
Show Gist options
  • Save jbma/5256759 to your computer and use it in GitHub Desktop.
Save jbma/5256759 to your computer and use it in GitHub Desktop.
<?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
@siddartha
Copy link

Merci pour ton aide ! :)
La fonction complète avec réécriture donc :
https://gist.github.com/siddartha/5270083

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment