Photo to src
This commit is contained in:
Hypolite Petovan 2017-11-30 20:33:48 -05:00 committed by GitHub
commit 0ae6f571da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 742 additions and 600 deletions

View file

@ -1,5 +1,7 @@
<?php
/**
* @file mod/contacts.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -10,7 +12,6 @@ use Friendica\Object\Contact;
require_once 'include/contact_selectors.php';
require_once 'mod/proxy.php';
require_once 'include/Photo.php';
function contacts_init(App $a) {
if (! local_user()) {
@ -309,7 +310,7 @@ function _contact_update_profile($contact_id) {
);
// Update the entry in the contact table
update_contact_avatar($data['photo'], local_user(), $contact_id, true);
Contact::updateAvatar($data['photo'], local_user(), $contact_id, true);
// Update the entry in the gcontact table
GlobalContact::updateFromProbe($data["url"]);

View file

@ -1,5 +1,7 @@
<?php
/**
* @file mod/crepair.php
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Database\DBM;
@ -84,18 +86,17 @@ function crepair_post(App $a) {
local_user()
);
if($photo) {
if ($photo) {
logger('mod-crepair: updating photo from ' . $photo);
require_once("include/Photo.php");
update_contact_avatar($photo,local_user(),$contact['id']);
Contact::updateAvatar($photo, local_user(), $contact['id']);
}
if($r)
info( t('Contact settings applied.') . EOL);
else
notice( t('Contact update failed.') . EOL);
if ($r) {
info(t('Contact settings applied.') . EOL);
} else {
notice(t('Contact update failed.') . EOL);
}
return;
}

View file

@ -25,6 +25,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Protocol\Diaspora;
require_once 'include/enotify.php';
@ -325,9 +326,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/
require_once 'include/Photo.php';
update_contact_avatar($contact['photo'],$uid,$contact_id);
Contact::updateAvatar($contact['photo'], $uid, $contact_id);
logger('dfrn_confirm: confirm - imported photos');
@ -676,9 +675,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
$photo = System::baseUrl() . '/images/person-175.jpg';
}
require_once 'include/Photo.php';
update_contact_avatar($photo,$local_uid,$dfrn_record);
Contact::updateAvatar($photo,$local_uid,$dfrn_record);
logger('dfrn_confirm: request - photos imported');

View file

@ -1,5 +1,4 @@
<?php
/**
* @file mod/dfrn_request.php
* @brief Module: dfrn_request
@ -11,23 +10,23 @@
* You also find a graphic which describes the confirmation process at
* https://github.com/friendica/friendica/blob/master/spec/dfrn2_contact_request.png
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
require_once 'include/enotify.php';
require_once 'include/group.php';
function dfrn_request_init(App $a) {
if($a->argc > 1)
function dfrn_request_init(App $a)
{
if ($a->argc > 1)
$which = $a->argv[1];
profile_load($a,$which);
profile_load($a, $which);
return;
}
@ -196,7 +195,7 @@ function dfrn_request_post(App $a) {
group_add_member(local_user(), '', $r[0]['id'], $def_gid);
if (isset($photo))
update_contact_avatar($photo, local_user(), $r[0]["id"], true);
Contact::updateAvatar($photo, local_user(), $r[0]["id"], true);
$forwardurl = System::baseUrl()."/contacts/".$r[0]['id'];
} else {
@ -587,7 +586,7 @@ function dfrn_request_post(App $a) {
);
if (DBM::is_result($r)) {
$contact_record = $r[0];
update_contact_avatar($photo, $uid, $contact_record["id"], true);
Contact::updateAvatar($photo, $uid, $contact_record["id"], true);
}
}

View file

@ -7,8 +7,7 @@
use Friendica\App;
use Friendica\Core\System;
require_once('include/Photo.php');
use Friendica\Object\Photo;
/**
* @param App $a

View file

@ -1,10 +1,11 @@
<?php
/**
* @file mod/install.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Database\DBM;
require_once "include/Photo.php";
use Friendica\Object\Photo;
$install_wizard_pass = 1;

View file

@ -1,10 +1,12 @@
<?php
/**
* @file mod/photo.php
*/
use Friendica\App;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
require_once('include/security.php');
require_once('include/Photo.php');
require_once 'include/security.php';
function photo_init(App $a) {
global $_SERVER;
@ -167,7 +169,7 @@ function photo_init(App $a) {
// Resize only if its not a GIF and it is supported by the library
if (($mimetype != "image/gif") && in_array($mimetype, Photo::supportedTypes())) {
$ph = new Photo($data, $mimetype);
if ($ph->is_valid()) {
if ($ph->isValid()) {
if (isset($customres) && $customres > 0 && $customres < 500) {
$ph->scaleImageSquare($customres);
}

View file

@ -1,5 +1,7 @@
<?php
/**
* @file mod/photos.php
*/
use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
@ -7,8 +9,8 @@ use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use Friendica\Object\Contact;
use Friendica\Object\Photo;
require_once 'include/Photo.php';
require_once 'include/photos.php';
require_once 'include/items.php';
require_once 'include/acl_selectors.php';
@ -422,7 +424,7 @@ function photos_post(App $a) {
);
if (DBM::is_result($r)) {
$ph = new Photo($r[0]['data'], $r[0]['type']);
if ($ph->is_valid()) {
if ($ph->isValid()) {
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
$ph->rotate($rotate_deg);
@ -808,7 +810,7 @@ function photos_post(App $a) {
$type = $_FILES['userfile']['type'];
}
if ($type == "") {
$type = guess_image_type($filename);
$type = Photo::guessImageType($filename);
}
logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
@ -837,7 +839,7 @@ function photos_post(App $a) {
$ph = new Photo($imagedata, $type);
if (! $ph->is_valid()) {
if (! $ph->isValid()) {
logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
notice( t('Unable to process image.') . EOL );
@unlink($src);

View file

@ -1,12 +1,13 @@
<?php
/**
* @file mod/profile_photo.php
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
require_once("include/Photo.php");
use Friendica\Object\Photo;
function profile_photo_init(App $a) {
@ -72,7 +73,7 @@ function profile_photo_post(App $a) {
$base_image = $r[0];
$im = new Photo($base_image['data'], $base_image['type']);
if($im->is_valid()) {
if ($im->isValid()) {
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
@ -150,13 +151,13 @@ function profile_photo_post(App $a) {
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
if ($filetype == "") {
$filetype = guess_image_type($filename);
$filetype = Photo::guessImageType($filename);
}
$maximagesize = Config::get('system','maximagesize');
$maximagesize = Config::get('system', 'maximagesize');
if (($maximagesize) && ($filesize > $maximagesize)) {
notice( sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
notice(sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize)) . EOL);
@unlink($src);
return;
}
@ -164,8 +165,8 @@ function profile_photo_post(App $a) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
if (! $ph->is_valid()) {
notice( t('Unable to process image.') . EOL );
if (! $ph->isValid()) {
notice(t('Unable to process image.') . EOL);
@unlink($src);
return;
}

View file

@ -1,10 +1,14 @@
<?php
// Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
/**
* @file mod/proxy.php
* @brief Based upon "Privacy Image Cache" by Tobias Hößl <https://github.com/CatoTH/>
*/
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Object\Photo;
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
@ -15,7 +19,6 @@ define('PROXY_SIZE_MEDIUM', 'medium');
define('PROXY_SIZE_LARGE', 'large');
require_once 'include/security.php';
require_once 'include/Photo.php';
function proxy_init(App $a) {
// Pictures are stored in one of the following ways:
@ -128,7 +131,7 @@ function proxy_init(App $a) {
// reduce quality - if it isn't a GIF
if ($mime != 'image/gif') {
$img = new Photo($img_str, $mime);
if ($img->is_valid()) {
if ($img->isValid()) {
$img_str = $img->imageString();
}
}
@ -172,7 +175,7 @@ function proxy_init(App $a) {
$cachefile = ''; // Clear the cachefile so that the dummy isn't stored
$valid = false;
$img = new Photo($img_str, 'image/png');
if ($img->is_valid()) {
if ($img->isValid()) {
$img->scaleImage(10);
$img_str = $img->imageString();
}
@ -190,7 +193,7 @@ function proxy_init(App $a) {
dba::insert('photo', $fields);
} else {
$img = new Photo($img_str, $mime);
if ($img->is_valid() && !$direct_cache && ($cachefile == '')) {
if ($img->isValid() && !$direct_cache && ($cachefile == '')) {
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
}
}
@ -201,7 +204,7 @@ function proxy_init(App $a) {
// reduce quality - if it isn't a GIF
if ($mime != 'image/gif') {
$img = new Photo($img_str, $mime);
if ($img->is_valid()) {
if ($img->isValid()) {
$img->scaleImage($size);
$img_str = $img->imageString();
}

View file

@ -13,8 +13,7 @@ use Friendica\App;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Database\DBM;
require_once 'include/Photo.php';
use Friendica\Object\Photo;
function wall_upload_post(App $a, $desktopmode = true) {
@ -163,7 +162,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
if ($filetype=="") {
$filetype=guess_image_type($filename);
$filetype=Photo::guessImageType($filename);
}
// If there is a temp name, then do a manual check
@ -193,7 +192,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
if (! $ph->is_valid()) {
if (! $ph->isValid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(array('error'=>$msg));