From: Evan Prodromou Date: Wed, 21 May 2008 15:54:48 +0000 (-0400) Subject: fixup default avatar urls by using common function X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9933e1e341593b90fab6d366706710d604a1b43f;p=quix0rs-gnu-social.git fixup default avatar urls by using common function darcs-hash:20080521155448-84dde-0e71fe5dccea49162911f80c65cd1e2a46043b14.gz --- diff --git a/actions/showstream.php b/actions/showstream.php index 25baf2fc9d..69d9ecef9d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -174,7 +174,7 @@ class ShowstreamAction extends StreamAction { 'href' => $subs->profileurl, 'class' => 'subscription')); $avatar = $subs->getAvatar(AVATAR_MINI_SIZE); - common_element('img', array('src' => (($avatar) ? $avatar->url : $config['avatar']['default']['mini']), + common_element('img', array('src' => (($avatar) ? $avatar->url : common_default_avatar(AVATAR_MINI_SIZE), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar mini', diff --git a/actions/subscribed.php b/actions/subscribed.php index 659118fb97..3218e07b86 100644 --- a/actions/subscribed.php +++ b/actions/subscribed.php @@ -69,7 +69,7 @@ class SubscribedAction extends Action { 'href' => $subs->profileurl, 'class' => 'subscription')); $avatar = $subs->getAvatar(AVATAR_STREAM_SIZE); - common_element('img', array('src' => (($avatar) ? $avatar->url : $config['avatar']['default']['stream']), + common_element('img', array('src' => (($avatar) ? $avatar->url : common_default_avatar(AVATAR_STREAM_SIZE)), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'class' => 'avatar stream', diff --git a/actions/subscriptions.php b/actions/subscriptions.php index c15bd53109..f111d0be2e 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -68,7 +68,7 @@ class SubscriptionsAction extends Action { common_element('img', array('src' => (($avatar) ? $avatar->url : - $config['avatar']['default']['stream']), + common_default_avatar(AVATAR_STREAM_SIZE)), 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'class' => 'avatar stream', diff --git a/lib/common.php b/lib/common.php index c6bc97d829..50d0110e28 100644 --- a/lib/common.php +++ b/lib/common.php @@ -45,13 +45,11 @@ $config = 'image' => 'http://i.creativecommons.org/l/by/3.0/88x31.png'), 'avatar' => array('directory' => INSTALLDIR . '/avatar', - 'path' => '/avatar')); - -# these depend on defaults above -$config['avatar']['default'] = - array('profile' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-profile.png', - 'stream' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-stream.png', - 'mini' => "http://".$config['site']['server'].$config['site']['path'].'/'.'theme/default/image/default-avatar-mini.png'); + 'path' => '/avatar', + 'default' => + array('profile' => 'theme/default/image/default-avatar-profile.png', + 'stream' => 'theme/default/image/default-avatar-stream.png', + 'mini' => 'theme/default/image/default-avatar-mini.png'))); $config['db'] = &PEAR::getStaticProperty('DB_DataObject','options'); diff --git a/lib/stream.php b/lib/stream.php index a9c01095ec..4b7d6ed24e 100644 --- a/lib/stream.php +++ b/lib/stream.php @@ -35,7 +35,7 @@ class StreamAction extends Action { 'id' => 'notice-' . $notice->id)); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); common_element_start('a', array('href' => $profile->profileurl)); - common_element('img', array('src' => ($avatar) ? $avatar->url : $config['avatar']['default']['stream'], + common_element('img', array('src' => ($avatar) ? $avatar->url : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar stream', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, diff --git a/lib/util.php b/lib/util.php index 9635c1abbd..09c4705a72 100644 --- a/lib/util.php +++ b/lib/util.php @@ -368,6 +368,14 @@ function common_avatar_url($filename) { return "http://".$config['site']['server'].$config['avatar']['path'].'/'.$filename; } +function common_default_avatar($size) { + static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile', + AVATAR_STREAM_SIZE => 'stream', + AVATAR_MINI_SIZE => 'mini'); + global $config; + return "http://".$config['site']['server'].$config['avatar']['path'].'/'.$config['avatar']['default'][$sizenames[$size]]; +} + function common_local_url($action, $args=NULL) { global $config; /* XXX: pretty URLs */