Change the default cover photo and the default_cover_photo logic.

This commit is contained in:
Mike Macgirvin 2022-06-26 15:40:09 -07:00
parent 80ee930617
commit 2cf3f9ed9d
13 changed files with 24 additions and 10 deletions

View file

@ -2435,6 +2435,7 @@ class Activity
if ($cover_photo) {
set_xconfig($url, 'system', 'cover_photo', $cover_photo);
import_remote_cover_photo($url, $xchan_hash);
}

View file

@ -1931,8 +1931,7 @@ class Channel
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
} else {
$default_cover = get_config('system', 'default_cover_photo', 'pexels-94622');
$cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ];
$cover = [ 'href' => z_root() . '/' . get_default_cover_photo($cover_width) ];
}
$o .= replace_macros(Theme::get_template('zcard.tpl'), array(
@ -2004,8 +2003,7 @@ class Channel
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale'];
} else {
$default_cover = get_config('system', 'default_cover_photo', 'pexels-94622');
$cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ];
$cover = [ 'href' => z_root() . '/' . get_default_cover_photo($cover_width) ];
}
$o .= replace_macros(Theme::get_template('zcard_embed.tpl'), array(

View file

@ -849,6 +849,7 @@ class Libzot
if (isset($arr['cover_photo']) && isset($arr['cover_photo']['url']) && strlen($arr['cover_photo']['url'])) {
set_xconfig($xchan_hash, 'system', 'cover_photo', $arr['cover_photo']['url']);
import_remote_cover_photo($arr['cover_photo']['url'], $xchan_hash);
}
if (isset($arr['signing_algorithm']) && strlen($arr['signing_algorithm'])) {
@ -939,6 +940,7 @@ class Libzot
if (isset($arr['cover_photo']) && isset($arr['cover_photo']['url']) && strlen($arr['cover_photo']['url'])) {
set_xconfig($xchan_hash, 'system', 'cover_photo', $arr['cover_photo']['url']);
import_remote_cover_photo($arr['cover_photo']['url'], $xchan_hash);
}
if ($import_photos) {

View file

@ -127,7 +127,9 @@ class Directory extends Controller
$safe_mode = Libzotdir::get_directory_setting($observer, 'safemode');
if (Config::Get('system','remote_cover_photos')) {
// replace with system.remote_cover_photos once work on this feature is complete
if (Config::Get('system','remote_cover_photos_directory')) {
$covers = Libzotdir::get_directory_setting($observer, 'covers');
} else {
$covers = false;

View file

@ -27,6 +27,9 @@ class Xp extends Controller
case '6':
$path = Channel::get_default_profile_photo(48);
break;
case '8':
$path = Channel::get_default_cover_photo(850);
break;
default:
break;
}

View file

@ -637,6 +637,9 @@ function sys_boot() {
define( 'DEFAULT_NOTIFY_ICON', '/images/z1-64.png' );
}
if (! defined('DEFAULT_COVER_PHOTO')) {
define('DEFAULT_COVER_PHOTO','pexels-7599590');
}
/*
* Try to open the database;
@ -2585,3 +2588,8 @@ function get_loadtime($module) {
return datetime_convert();
}
function get_default_cover_photo($size) {
$default_cover = get_config('system', 'default_cover_photo', DEFAULT_COVER_PHOTO);
return 'images/default_cover_photos/' . $default_cover . '/' . $size . '.jpg';
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

View file

@ -355,16 +355,16 @@ function import_remote_cover_photo($src, $xchan)
if ($result['success']) {
$info = getimagesize($orig);
if (!$info) {
logger('storage failed.');
unlink($orig);
logger('storage failure: unrecognisable photo.');
return false;
}
$type = $info['mime'];
$imagick_path = Config::Get('system','imagick_convert_path');
if ($imagick_path && file_exists($imagick_path)) {
exec($imagick_path . ' '
. escapeshellarg(PROJECT_BASE . '/' . $orig)
. ' -resize 425x139 '
. escapeshellarg(PROJECT_BASE . '/' . $path . '-9')
. ' -resize 850x478 '
. escapeshellarg(PROJECT_BASE . '/' . $path . '-8')
);
}
}