鍔犻焀ordPress锛氬皢Gravatar澶村儚缂撳瓨鍒版湰鍦

2014 年 3 月 7 日4220

銆浠涔堟槸Gravatar澶村儚?

銆銆Gravatar澶村儚鐩稿綋浜庝綘鐨凲Q澶村儚锛屼唬琛ㄧ殑灏辨槸浣犲湪缃戠粶鐨勪釜浜哄舰璞★紝鎵浠ュ悇绉嶇ぞ浜ょ▼搴忛兘涓嶈兘鍏嶉櫎澶村儚鐨勪娇鐢锛學ordPress涔熶笉渚嬪栥

銆銆浼楁墍鍛ㄧ煡锛學ordPress鐨凣ravatar澶村儚榛樿や細鏄 “http://http://www.zjjv.com///avatar/50ad321e53732e7b5a6593c3223fa9b0” 杩欐牱鐨勬牸寮忥紝 鑰屽浗澶栨湇鍔″櫒鍦ㄥぉ鏈濇樉绀洪熷害鏋佹參锛屾湁鏃跺欏艰嚧涓涓椤甸潰灏卞洜涓轰竴涓灏忓皬鐨勫ご鍍忥紝寰堜箙鎵嶆墦寮瀹屽叏銆傛洿鏈夋椂鍊欑敋鑷充笉鑳芥墦寮锛屼竴涓澶х孩鍙夊弶锛屽緢鏄褰卞搷鐢ㄦ埛浣撻獙锛屼互鍙婄綉绔欐墦寮閫熷害銆

銆銆浠婂ぉ鐨勬暀绋嬪氨鏄锛屽皢WordPress鐨凣ravatar澶村儚缂撳瓨鍒版湰鍦版湇鍔″櫒锛屽姞閫焀ordPress杩愯岋紝濡傛灉浣犱篃鏄鍥藉唴鐨勬湇鍔″櫒锛岃繖鏍锋墦寮閫熷害灏变細蹇寰堝氥

銆缂撳瓨浣跨敤鍓嶆彁

銆銆纭瀹氳嚜宸辩殑妯℃澘鎴栬呬富棰樼敤鐨勬槸 WordPress 2.7 浠ュ悗鎵嶆湁鐨 wp_list_comments()锛屽傛灉涓嶆竻妤氾紝浣犲彲浠ュ湪浣犵殑comments.php鎴栬協unctions.php涓鎼滅储璇曚竴璇曪紝杩樻槸涓嶇煡閬撳氨鐩存帴璺宠繃銆

銆缂撳瓨Gravatar澶村儚 寤虹珛缂撳瓨鐩褰

銆銆鍦 wp-content 鐨勫悓绾х洰褰曞缓绔嬫枃浠跺す锛歛vatar锛屾枃浠跺す鏉冮檺涓猴細755锛屽傛灉涓嶈屾枃浠跺す鏉冮檺灏辫剧疆鎴777, 杩欐槸 gravatar澶村儚 缂撳瓨鐨勮矾寰勩

銆璁剧疆榛樿ゅご鍍

銆銆鍒朵綔涓寮犻粯璁ゅご鍍忥紝涔熷彲浠ョ洿鎺ュ湪wordpress鍚庡彴銆嬭剧疆銆嬭ㄨ 閲宑opy涓寮,鍛藉悕涓"default.jpg" 锛屾斁鍦 avatar 鏂囦欢澶归噷闈銆

銆銆娣诲姞缂撳瓨浠g爜

銆銆灏嗕笅闈㈢殑浠g爜澶嶅埗鍒版ā鏉跨殑 functions.php 鏂囦欢涓鍗冲彲锛

銆銆function my_avatar($avatar) { $tmp = strpos($avatar, 'http'); $g = substr($avatar, $tmp, strpos($avatar, "'", $tmp) - $tmp); $tmp = strpos($g, 'avatar/') + 7; $f = substr($g, $tmp, strpos($g, "?", $tmp) - $tmp); $w = get_bloginfo('wpurl'); $e = ABSPATH .'avatar/'. $f .'.jpg'; $t = 1209600; //瑷瀹14澶, 鍠浣:绉 if ( !is_file($e) || (time() - filemtime($e)) > $t ) { //鐣堕牠鍍忎笉瀛樺湪鎴栨枃浠惰秴閬14澶╂墠鏇存柊 copy(htmlspecialchars_decode($g), $e); } else $avatar = strtr($avatar, array($g => $w.'/avatar/'.$f.'.jpg')); if (filesize($e) < 500) copy($w.'/avatar/default.jpg', $e); return $avatar; } add_filter('get_avatar', 'my_avatar');

銆銆OK锛屾敹宸ャ傚埛鏂板嚑涓缃戦〉锛岀湅鐪媋vatar鏂囦欢澶逛腑鏄鍚︽湁缂撳瓨鍐呭癸紝濡傛灉娌℃湁鐨勮瘽锛岃存槑缂撳瓨澶辫触锛岃ユ柟娉曚笉閫傚悎浣犮傚叿浣撲唬鐮佹潵鑷猈illin锛屽備綍璁剧疆澶村儚璇风櫨搴︼紝绫讳技鏁欑▼寰堝氾紝灏婇噸浠栦汉鍔冲姩鎴愭灉锛岃浆杞借锋敞鏄庢潵鑷獁ordpress杩凤細http://http://www.zjjv.com//,璋㈣阿鍚勪綅鍚堜綔!

0 0