Separate Object\Photo into Model\Photo and Object\Image
- Renamed a bunch of functions to shorter or clearer names
This commit is contained in:
parent
7499824381
commit
3fc3e67b70
22 changed files with 464 additions and 408 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
/**
|
||||
* @param App $a
|
||||
|
@ -66,7 +66,7 @@ function fbrowser_content(App $a) {
|
|||
|
||||
function _map_files1($rr){
|
||||
$a = get_app();
|
||||
$types = Photo::supportedTypes();
|
||||
$types = Image::supportedTypes();
|
||||
$ext = $types[$rr['type']];
|
||||
$filename_e = $rr['filename'];
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
$install_wizard_pass = 1;
|
||||
|
||||
|
@ -503,7 +503,7 @@ function check_imagik(&$checks) {
|
|||
|
||||
if (class_exists('Imagick')) {
|
||||
$imagick = true;
|
||||
$supported = Photo::supportedTypes();
|
||||
$supported = Image::supportedTypes();
|
||||
if (array_key_exists('image/gif', $supported)) {
|
||||
$gif = true;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
use Friendica\App;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
require_once 'include/security.php';
|
||||
|
||||
|
@ -75,7 +75,7 @@ function photo_init(App $a) {
|
|||
|
||||
$uid = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $person);
|
||||
|
||||
foreach (Photo::supportedTypes() AS $m => $e) {
|
||||
foreach (Image::supportedTypes() AS $m => $e) {
|
||||
$uid = str_replace('.'.$e, '', $uid);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ function photo_init(App $a) {
|
|||
$resolution = 0;
|
||||
$photo = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $photo);
|
||||
|
||||
foreach (Photo::supportedTypes() AS $m => $e) {
|
||||
foreach (Image::supportedTypes() AS $m => $e) {
|
||||
$photo = str_replace('.'.$e, '', $photo);
|
||||
}
|
||||
|
||||
|
@ -167,14 +167,14 @@ 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->isValid()) {
|
||||
if (($mimetype != "image/gif") && in_array($mimetype, Image::supportedTypes())) {
|
||||
$Image = new Image($data, $mimetype);
|
||||
if ($Image->isValid()) {
|
||||
if (isset($customres) && $customres > 0 && $customres < 500) {
|
||||
$ph->scaleImageSquare($customres);
|
||||
$Image->scaleToSquare($customres);
|
||||
}
|
||||
$data = $ph->imageString();
|
||||
$mimetype = $ph->getType();
|
||||
$data = $Image->asString();
|
||||
$mimetype = $Image->getType();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,10 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Object\Contact;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
require_once 'include/photos.php';
|
||||
require_once 'include/items.php';
|
||||
|
@ -136,7 +137,7 @@ function photos_post(App $a) {
|
|||
logger('mod_photos: REQUEST ' . print_r($_REQUEST,true), LOGGER_DATA);
|
||||
logger('mod_photos: FILES ' . print_r($_FILES,true), LOGGER_DATA);
|
||||
|
||||
$phototypes = Photo::supportedTypes();
|
||||
$phototypes = Image::supportedTypes();
|
||||
|
||||
$can_post = false;
|
||||
$visitor = 0;
|
||||
|
@ -424,16 +425,16 @@ function photos_post(App $a) {
|
|||
intval($page_owner_uid)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$ph = new Photo($r[0]['data'], $r[0]['type']);
|
||||
if ($ph->isValid()) {
|
||||
$Image = new Image($r[0]['data'], $r[0]['type']);
|
||||
if ($Image->isValid()) {
|
||||
$rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
|
||||
$ph->rotate($rotate_deg);
|
||||
$Image->rotate($rotate_deg);
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 0",
|
||||
dbesc($ph->imageString()),
|
||||
dbesc($Image->asString()),
|
||||
intval($height),
|
||||
intval($width),
|
||||
dbesc($resource_id),
|
||||
|
@ -441,12 +442,12 @@ function photos_post(App $a) {
|
|||
);
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$ph->scaleImage(640);
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$Image->scaleDown(640);
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 1",
|
||||
dbesc($ph->imageString()),
|
||||
dbesc($Image->asString()),
|
||||
intval($height),
|
||||
intval($width),
|
||||
dbesc($resource_id),
|
||||
|
@ -455,12 +456,12 @@ function photos_post(App $a) {
|
|||
}
|
||||
|
||||
if ($width > 320 || $height > 320) {
|
||||
$ph->scaleImage(320);
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$Image->scaleDown(320);
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
$x = q("UPDATE `photo` SET `data` = '%s', `height` = %d, `width` = %d WHERE `resource-id` = '%s' AND `uid` = %d AND `scale` = 2",
|
||||
dbesc($ph->imageString()),
|
||||
dbesc($Image->asString()),
|
||||
intval($height),
|
||||
intval($width),
|
||||
dbesc($resource_id),
|
||||
|
@ -811,7 +812,7 @@ function photos_post(App $a) {
|
|||
$type = $_FILES['userfile']['type'];
|
||||
}
|
||||
if ($type == "") {
|
||||
$type = Photo::guessImageType($filename);
|
||||
$type = Image::guessType($filename);
|
||||
}
|
||||
|
||||
logger('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG);
|
||||
|
@ -838,9 +839,9 @@ function photos_post(App $a) {
|
|||
|
||||
$imagedata = @file_get_contents($src);
|
||||
|
||||
$ph = new Photo($imagedata, $type);
|
||||
$Image = new Image($imagedata, $type);
|
||||
|
||||
if (! $ph->isValid()) {
|
||||
if (! $Image->isValid()) {
|
||||
logger('mod/photos.php: photos_post(): unable to process image' , LOGGER_DEBUG);
|
||||
notice( t('Unable to process image.') . EOL );
|
||||
@unlink($src);
|
||||
|
@ -849,7 +850,7 @@ function photos_post(App $a) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$exif = $ph->orient($src);
|
||||
$exif = $Image->orient($src);
|
||||
@unlink($src);
|
||||
|
||||
$max_length = Config::get('system', 'max_image_length');
|
||||
|
@ -857,17 +858,17 @@ function photos_post(App $a) {
|
|||
$max_length = MAX_IMAGE_LENGTH;
|
||||
}
|
||||
if ($max_length > 0) {
|
||||
$ph->scaleImage($max_length);
|
||||
$Image->scaleDown($max_length);
|
||||
}
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
$smallest = 0;
|
||||
|
||||
$photo_hash = photo_new_resource();
|
||||
|
||||
$r = $ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
|
||||
if (! $r) {
|
||||
logger('mod/photos.php: photos_post(): image store failed' , LOGGER_DEBUG);
|
||||
|
@ -876,14 +877,14 @@ function photos_post(App $a) {
|
|||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$ph->scaleImage(640);
|
||||
$ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$Image->scaleDown(640);
|
||||
Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 1, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$smallest = 1;
|
||||
}
|
||||
|
||||
if ($width > 320 || $height > 320) {
|
||||
$ph->scaleImage(320);
|
||||
$ph->store($page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$Image->scaleDown(320);
|
||||
Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 2, 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
|
||||
$smallest = 2;
|
||||
}
|
||||
|
||||
|
@ -932,7 +933,7 @@ function photos_post(App $a) {
|
|||
$arr['origin'] = 1;
|
||||
|
||||
$arr['body'] = '[url=' . System::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $photo_hash . ']'
|
||||
. '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/img]'
|
||||
. '[img]' . System::baseUrl() . "/photo/{$photo_hash}-{$smallest}.".$Image->getExt() . '[/img]'
|
||||
. '[/url]';
|
||||
|
||||
$item_id = item_store($arr);
|
||||
|
@ -980,7 +981,7 @@ function photos_content(App $a) {
|
|||
return;
|
||||
}
|
||||
|
||||
$phototypes = Photo::supportedTypes();
|
||||
$phototypes = Image::supportedTypes();
|
||||
|
||||
$_SESSION['photo_return'] = $a->cmd;
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@ use Friendica\Core\Config;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
function profile_photo_init(App $a) {
|
||||
|
||||
|
@ -72,27 +73,27 @@ function profile_photo_post(App $a) {
|
|||
|
||||
$base_image = $r[0];
|
||||
|
||||
$im = new Photo($base_image['data'], $base_image['type']);
|
||||
if ($im->isValid()) {
|
||||
$im->cropImage(175,$srcX,$srcY,$srcW,$srcH);
|
||||
$Image = new Image($base_image['data'], $base_image['type']);
|
||||
if ($Image->isValid()) {
|
||||
$Image->crop(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);
|
||||
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 4, $is_default_profile);
|
||||
|
||||
if ($r === false) {
|
||||
notice ( sprintf(t('Image size reduction [%s] failed.'),"175") . EOL );
|
||||
}
|
||||
|
||||
$im->scaleImage(80);
|
||||
$Image->scaleDown(80);
|
||||
|
||||
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
|
||||
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 5, $is_default_profile);
|
||||
|
||||
if ($r === false) {
|
||||
notice( sprintf(t('Image size reduction [%s] failed.'),"80") . EOL );
|
||||
}
|
||||
|
||||
$im->scaleImage(48);
|
||||
$Image->scaleDown(48);
|
||||
|
||||
$r = $im->store(local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
|
||||
$r = Photo::store($Image, local_user(), 0, $base_image['resource-id'],$base_image['filename'], t('Profile Photos'), 6, $is_default_profile);
|
||||
|
||||
if ($r === false) {
|
||||
notice( sprintf(t('Image size reduction [%s] failed.'),"48") . EOL );
|
||||
|
@ -107,15 +108,15 @@ function profile_photo_post(App $a) {
|
|||
);
|
||||
|
||||
$r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `self` AND `uid` = %d",
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $im->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-6.' . $Image->getExt()),
|
||||
intval(local_user())
|
||||
);
|
||||
} else {
|
||||
$r = q("update profile set photo = '%s', thumb = '%s' where id = %d and uid = %d",
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $im->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $im->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-4.' . $Image->getExt()),
|
||||
dbesc(System::baseUrl() . '/photo/' . $base_image['resource-id'] . '-5.' . $Image->getExt()),
|
||||
intval($_REQUEST['profile']),
|
||||
intval(local_user())
|
||||
);
|
||||
|
@ -151,7 +152,7 @@ function profile_photo_post(App $a) {
|
|||
$filesize = intval($_FILES['userfile']['size']);
|
||||
$filetype = $_FILES['userfile']['type'];
|
||||
if ($filetype == "") {
|
||||
$filetype = Photo::guessImageType($filename);
|
||||
$filetype = Image::guessType($filename);
|
||||
}
|
||||
|
||||
$maximagesize = Config::get('system', 'maximagesize');
|
||||
|
@ -163,7 +164,7 @@ function profile_photo_post(App $a) {
|
|||
}
|
||||
|
||||
$imagedata = @file_get_contents($src);
|
||||
$ph = new Photo($imagedata, $filetype);
|
||||
$ph = new Image($imagedata, $filetype);
|
||||
|
||||
if (! $ph->isValid()) {
|
||||
notice(t('Unable to process image.') . EOL);
|
||||
|
@ -239,7 +240,7 @@ function profile_photo_content(App $a) {
|
|||
goaway(System::baseUrl() . '/profiles');
|
||||
return; // NOTREACHED
|
||||
}
|
||||
$ph = new Photo($r[0]['data'], $r[0]['type']);
|
||||
$ph = new Image($r[0]['data'], $r[0]['type']);
|
||||
profile_photo_crop_ui_head($a, $ph);
|
||||
// go ahead as we have jus uploaded a new photo to crop
|
||||
}
|
||||
|
@ -288,22 +289,22 @@ function profile_photo_content(App $a) {
|
|||
|
||||
|
||||
if(! function_exists('profile_photo_crop_ui_head')) {
|
||||
function profile_photo_crop_ui_head(App $a, $ph) {
|
||||
function profile_photo_crop_ui_head(App $a, Image $Image) {
|
||||
$max_length = Config::get('system','max_image_length');
|
||||
if (! $max_length) {
|
||||
$max_length = MAX_IMAGE_LENGTH;
|
||||
}
|
||||
if ($max_length > 0) {
|
||||
$ph->scaleImage($max_length);
|
||||
$Image->scaleDown($max_length);
|
||||
}
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
if ($width < 175 || $height < 175) {
|
||||
$ph->scaleImageUp(200);
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$Image->scaleUp(200);
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
}
|
||||
|
||||
$hash = photo_new_resource();
|
||||
|
@ -311,7 +312,7 @@ function profile_photo_crop_ui_head(App $a, $ph) {
|
|||
|
||||
$smallest = 0;
|
||||
|
||||
$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
|
||||
$r = Photo::store($Image, local_user(), 0 , $hash, $filename, t('Profile Photos'), 0 );
|
||||
|
||||
if ($r) {
|
||||
info( t('Image uploaded successfully.') . EOL );
|
||||
|
@ -320,8 +321,8 @@ function profile_photo_crop_ui_head(App $a, $ph) {
|
|||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$ph->scaleImage(640);
|
||||
$r = $ph->store(local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
|
||||
$Image->scaleDown(640);
|
||||
$r = Photo::store($Image, local_user(), 0 , $hash, $filename, t('Profile Photos'), 1 );
|
||||
|
||||
if ($r === false) {
|
||||
notice( sprintf(t('Image size reduction [%s] failed.'),"640") . EOL );
|
||||
|
@ -332,7 +333,7 @@ function profile_photo_crop_ui_head(App $a, $ph) {
|
|||
|
||||
$a->config['imagecrop'] = $hash;
|
||||
$a->config['imagecrop_resolution'] = $smallest;
|
||||
$a->config['imagecrop_ext'] = $ph->getExt();
|
||||
$a->config['imagecrop_ext'] = $Image->getExt();
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array());
|
||||
$a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), array());
|
||||
return;
|
||||
|
|
|
@ -8,7 +8,8 @@ use Friendica\App;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
define('PROXY_DEFAULT_TIME', 86400); // 1 Day
|
||||
|
||||
|
@ -130,9 +131,9 @@ 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->isValid()) {
|
||||
$img_str = $img->imageString();
|
||||
$Image = new Image($img_str, $mime);
|
||||
if ($Image->isValid()) {
|
||||
$img_str = $Image->asString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,10 +175,10 @@ function proxy_init(App $a) {
|
|||
$mime = 'image/png';
|
||||
$cachefile = ''; // Clear the cachefile so that the dummy isn't stored
|
||||
$valid = false;
|
||||
$img = new Photo($img_str, 'image/png');
|
||||
if ($img->isValid()) {
|
||||
$img->scaleImage(10);
|
||||
$img_str = $img->imageString();
|
||||
$Image = new Image($img_str, 'image/png');
|
||||
if ($Image->isValid()) {
|
||||
$Image->scaleDown(10);
|
||||
$img_str = $Image->asString();
|
||||
}
|
||||
} elseif ($mime != 'image/jpeg' && !$direct_cache && $cachefile == '') {
|
||||
$image = @imagecreatefromstring($img_str);
|
||||
|
@ -192,9 +193,9 @@ function proxy_init(App $a) {
|
|||
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime);
|
||||
dba::insert('photo', $fields);
|
||||
} else {
|
||||
$img = new Photo($img_str, $mime);
|
||||
if ($img->isValid() && !$direct_cache && ($cachefile == '')) {
|
||||
$img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
|
||||
$Image = new Image($img_str, $mime);
|
||||
if ($Image->isValid() && !$direct_cache && ($cachefile == '')) {
|
||||
Photo::store($Image, 0, 0, $urlhash, $_REQUEST['url'], '', 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,10 +204,10 @@ 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->isValid()) {
|
||||
$img->scaleImage($size);
|
||||
$img_str = $img->imageString();
|
||||
$Image = new Image($img_str, $mime);
|
||||
if ($Image->isValid()) {
|
||||
$Image->scaleDown($size);
|
||||
$img_str = $Image->asString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ use Friendica\App;
|
|||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Object\Photo;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Object\Image;
|
||||
|
||||
function wall_upload_post(App $a, $desktopmode = true) {
|
||||
|
||||
|
@ -161,8 +162,8 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
$filetype = "";
|
||||
}
|
||||
|
||||
if ($filetype=="") {
|
||||
$filetype=Photo::guessImageType($filename);
|
||||
if ($filetype == "") {
|
||||
$filetype = Image::guessType($filename);
|
||||
}
|
||||
|
||||
// If there is a temp name, then do a manual check
|
||||
|
@ -190,9 +191,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
}
|
||||
|
||||
$imagedata = @file_get_contents($src);
|
||||
$ph = new Photo($imagedata, $filetype);
|
||||
$Image = new Image($imagedata, $filetype);
|
||||
|
||||
if (! $ph->isValid()) {
|
||||
if (! $Image->isValid()) {
|
||||
$msg = t('Unable to process image.');
|
||||
if ($r_json) {
|
||||
echo json_encode(array('error'=>$msg));
|
||||
|
@ -203,7 +204,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$ph->orient($src);
|
||||
$Image->orient($src);
|
||||
@unlink($src);
|
||||
|
||||
$max_length = Config::get('system', 'max_image_length');
|
||||
|
@ -211,12 +212,12 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
$max_length = MAX_IMAGE_LENGTH;
|
||||
}
|
||||
if ($max_length > 0) {
|
||||
$ph->scaleImage($max_length);
|
||||
$Image->scaleDown($max_length);
|
||||
logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$width = $ph->getWidth();
|
||||
$height = $ph->getHeight();
|
||||
$width = $Image->getWidth();
|
||||
$height = $Image->getHeight();
|
||||
|
||||
$hash = photo_new_resource();
|
||||
|
||||
|
@ -229,7 +230,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
|
||||
$defperm = '<' . $default_cid . '>';
|
||||
|
||||
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
|
||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
|
||||
|
||||
if (! $r) {
|
||||
$msg = t('Image upload failed.');
|
||||
|
@ -242,16 +243,16 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
}
|
||||
|
||||
if ($width > 640 || $height > 640) {
|
||||
$ph->scaleImage(640);
|
||||
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
|
||||
$Image->scaleDown(640);
|
||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
|
||||
if ($r) {
|
||||
$smallest = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($width > 320 || $height > 320) {
|
||||
$ph->scaleImage(320);
|
||||
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
|
||||
$Image->scaleDown(320);
|
||||
$r = Photo::store($Image, $page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
|
||||
if ($r && ($smallest == 0)) {
|
||||
$smallest = 2;
|
||||
}
|
||||
|
@ -280,8 +281,8 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
$picture["height"] = $r[0]["height"];
|
||||
$picture["type"] = $r[0]["type"];
|
||||
$picture["albumpage"] = System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash;
|
||||
$picture["picture"] = System::baseUrl() . "/photo/{$hash}-0." . $ph->getExt();
|
||||
$picture["preview"] = System::baseUrl() . "/photo/{$hash}-{$smallest}." . $ph->getExt();
|
||||
$picture["picture"] = System::baseUrl() . "/photo/{$hash}-0." . $Image->getExt();
|
||||
$picture["preview"] = System::baseUrl() . "/photo/{$hash}-{$smallest}." . $Image->getExt();
|
||||
|
||||
if ($r_json) {
|
||||
echo json_encode(array('picture'=>$picture));
|
||||
|
@ -299,9 +300,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
|
|||
/* mod Waitman Gobble NO WARRANTY */
|
||||
// if we get the signal then return the image url info in BBCODE
|
||||
if ($_REQUEST['hush']!='yeah') {
|
||||
echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
|
||||
echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
|
||||
} else {
|
||||
$m = '[url='.System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.System::baseUrl()."/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]";
|
||||
$m = '[url='.System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.System::baseUrl()."/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]";
|
||||
return($m);
|
||||
}
|
||||
/* mod Waitman Gobble NO WARRANTY */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue