Skip to content

Commit

Permalink
Proper Caching for Profile Images
Browse files Browse the repository at this point in the history
  • Loading branch information
jptksc committed Sep 8, 2013
1 parent 5ed91ea commit 271799a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions dropplets/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,23 @@ function count_premium_templates($type = 'all') {
define('IS_HOME', $is_home);

/*-----------------------------------------------------------------------------------*/
/* Get Profile Image (This Needs to be Cached)
/* Get Profile Image
/*-----------------------------------------------------------------------------------*/

function get_twitter_profile_img($username) {

// Temporary fix for profile images.
$image_url = 'http://dropplets.com/profiles/?id='.$username.'';
return $image_url;

// Get the cached profile image.
$profile_image = './cache/'.$username.'.jpg';

// Cache the image if it doesn't already exist.
if (!file_exists($profile_image)) {
$image_url = 'http://dropplets.com/profiles/?id='.$username.'';
$image = file_get_contents($image_url);
file_put_contents('./cache/'.$username.'.jpg', $image);
}

// Return the image URL.
return $profile_image;
}

/*-----------------------------------------------------------------------------------*/
Expand Down

0 comments on commit 271799a

Please sign in to comment.