首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elgg轮廓图像

Elgg轮廓图像
EN

Stack Overflow用户
提问于 2014-03-18 06:08:17
回答 1查看 281关注 0票数 1

我正在开发一个在elgg插件,其中有一些图像为配置文件图标。在那个插件中,有不同大小的文件用于单个图像。

代码语言:javascript
复制
train.jpg = Height : 100px || Width : 100px

train_25px.jpg = Height : 25px || Width : 25px

就像上面一样,我剪下了图像。有关于25 images + 25 cropped images

我希望为每个用户定义一个图像,并在任何时候调用该图像,而不需要在另一个位置重新创建相同的图像。

例如:

原址:sitepath/mod/plugin_name/graphic/profile_icon1/master.jpg

用户图像定位:site_temp_path/year/month/user_guid/master.jpg

我的php函数是

代码语言:javascript
复制
global $CONFIG;

function identicon_init() {
    extend_view('profile/editicon', 'identicon/editicon');
    register_action('identicon/preference', false, $CONFIG->pluginspath . 'identicon/actions/preference.php');
    register_plugin_hook('entity:icon:url', 'user', 'identicon_usericon_hook', 900); 
}  


function identicon_usericon_hook($hook, $entity_type, $returnvalue, $params) {

    if (($hook == 'entity:icon:url') && ($params['entity'] instanceof ElggUser)) {
        $ent = $params['entity'];
        if ($ent->preferIdenticon || !$returnvalue) {
            return identicon_url($ent, $params['size']);
        }
    } else {
        return $returnvalue;
    }
}


function identicon_url($ent, $size) {
    global $CONFIG;
    return $CONFIG->wwwroot . 'mod/fp_auto_profile_image/img.php?entity=' . $ent->getGUID() . '&size=' . $size;
}

register_elgg_event_handler('init','system','identicon_init');
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-16 11:27:58

使用elgg_get_data_path()代替$CONFIG->wwwroot

然后创建icon.php并在identicon_usericon_hook中返回到icon.php的路径以及所需的和大小,然后在icon.php中有以下代码

代码语言:javascript
复制
$news_guid = get_input('guid');

$contents = readfile(filepath);
$size = strtolower(get_input('size'));
if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar')))
$size = "large";


header("Content-type: image/jpeg");
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true);
header("Pragma: public");
header("Cache-Control: public");
header("Content-Length: " . strlen($contents));
header("ETag: \"$etag\"");
echo $contents;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22471595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档