summaryrefslogtreecommitdiffstats
path: root/apps/contacts/thumbnail.php
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-01-19 18:28:17 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-01-19 18:28:17 +0100
commit137c63037704f85ebcba4ce4725750fd68a23c22 (patch)
tree7f62095700dd03169d6f56bc215cf96f47053286 /apps/contacts/thumbnail.php
parent5bd117dd6db9e1ea27404970faf0a94490fce994 (diff)
downloadnextcloud-server-137c63037704f85ebcba4ce4725750fd68a23c22.tar.gz
nextcloud-server-137c63037704f85ebcba4ce4725750fd68a23c22.zip
Optimizations and more aggressive caching.
Diffstat (limited to 'apps/contacts/thumbnail.php')
-rw-r--r--apps/contacts/thumbnail.php25
1 files changed, 10 insertions, 15 deletions
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index 507e1c7b302..f2b57014785 100644
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -22,22 +22,16 @@
// Init owncloud
require_once('../../lib/base.php');
-OC_JSON::checkLoggedIn();
-//OC_Util::checkLoggedIn();
+//OC_JSON::checkLoggedIn();
+OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
-if(!function_exists('imagecreatefromjpeg')) {
- OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG);
- header('Content-Type: image/png');
- // TODO: Check if it works to read the file and echo the content.
- return 'img/person.png';
-}
-
function getStandardImage(){
$date = new DateTime('now');
$date->add(new DateInterval('P10D'));
header('Expires: '.$date->format(DateTime::RFC850));
header('Cache-Control: cache');
+ header('Pragma: cache');
header('Location: '.OC_Helper::imagePath('contacts', 'person.png'));
exit();
// $src_img = imagecreatefrompng('img/person.png');
@@ -46,6 +40,11 @@ function getStandardImage(){
// imagedestroy($src_img);
}
+if(!function_exists('imagecreatefromjpeg')) {
+ OC_Log::write('contacts','thumbnail.php. GD module not installed',OC_Log::DEBUG);
+ getStandardImage();
+ exit();
+}
$id = $_GET['id'];
@@ -76,18 +75,14 @@ if( is_null($content)){
$thumbnail_size = 23;
-// Finf the photo from VCard.
+// Find the photo from VCard.
foreach($content->children as $child){
if($child->name == 'PHOTO'){
- foreach($child->parameters as $parameter){
- if( $parameter->name == 'TYPE' ){
- $mime = $parameter->value;
- }
- }
$image = new OC_Image();
if($image->loadFromBase64($child->value)) {
if($image->centerCrop()) {
if($image->resize($thumbnail_size)) {
+ header('ETag: '.md5($child->value));
if(!$image()) {
OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR);
getStandardImage();