mirror of
https://github.com/owncloudarchive/contacts.git
synced 2025-01-18 07:52:21 +01:00
Optimizations and more aggressive caching.
This commit is contained in:
parent
10235f28a2
commit
276f45de4d
@ -22,22 +22,16 @@
|
|||||||
|
|
||||||
// Init owncloud
|
// Init owncloud
|
||||||
require_once('../../lib/base.php');
|
require_once('../../lib/base.php');
|
||||||
OC_JSON::checkLoggedIn();
|
//OC_JSON::checkLoggedIn();
|
||||||
//OC_Util::checkLoggedIn();
|
OC_Util::checkLoggedIn();
|
||||||
OC_Util::checkAppEnabled('contacts');
|
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(){
|
function getStandardImage(){
|
||||||
$date = new DateTime('now');
|
$date = new DateTime('now');
|
||||||
$date->add(new DateInterval('P10D'));
|
$date->add(new DateInterval('P10D'));
|
||||||
header('Expires: '.$date->format(DateTime::RFC850));
|
header('Expires: '.$date->format(DateTime::RFC850));
|
||||||
header('Cache-Control: cache');
|
header('Cache-Control: cache');
|
||||||
|
header('Pragma: cache');
|
||||||
header('Location: '.OC_Helper::imagePath('contacts', 'person.png'));
|
header('Location: '.OC_Helper::imagePath('contacts', 'person.png'));
|
||||||
exit();
|
exit();
|
||||||
// $src_img = imagecreatefrompng('img/person.png');
|
// $src_img = imagecreatefrompng('img/person.png');
|
||||||
@ -46,6 +40,11 @@ function getStandardImage(){
|
|||||||
// imagedestroy($src_img);
|
// 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'];
|
$id = $_GET['id'];
|
||||||
|
|
||||||
@ -76,18 +75,14 @@ if( is_null($content)){
|
|||||||
|
|
||||||
$thumbnail_size = 23;
|
$thumbnail_size = 23;
|
||||||
|
|
||||||
// Finf the photo from VCard.
|
// Find the photo from VCard.
|
||||||
foreach($content->children as $child){
|
foreach($content->children as $child){
|
||||||
if($child->name == 'PHOTO'){
|
if($child->name == 'PHOTO'){
|
||||||
foreach($child->parameters as $parameter){
|
|
||||||
if( $parameter->name == 'TYPE' ){
|
|
||||||
$mime = $parameter->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$image = new OC_Image();
|
$image = new OC_Image();
|
||||||
if($image->loadFromBase64($child->value)) {
|
if($image->loadFromBase64($child->value)) {
|
||||||
if($image->centerCrop()) {
|
if($image->centerCrop()) {
|
||||||
if($image->resize($thumbnail_size)) {
|
if($image->resize($thumbnail_size)) {
|
||||||
|
header('ETag: '.md5($child->value));
|
||||||
if(!$image()) {
|
if(!$image()) {
|
||||||
OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR);
|
OC_Log::write('contacts','thumbnail.php. Couldn\'t display thumbnail for ID '.$id,OC_Log::ERROR);
|
||||||
getStandardImage();
|
getStandardImage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user