亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    如何為Gravatar頭像添加ALT屬性

    下面由WordPress教程欄目給大家介紹為Gravatar頭像添加ALT屬性的方法,希望對需要的朋友有所幫助!

    如何為Gravatar頭像添加ALT屬性

    圖片ALT屬性不僅有利于搜索引擎索引圖片,而且當圖片無法加載的時候,會顯示圖片的ALT信息。

    WordPress文章插入圖片時可以在“替代文本”中填寫ALT信息,但評論中的大量Gravatar頭像一般主題都沒有ALT屬性,其實WP以為我們預(yù)設(shè)了Gravatar頭像ALT屬性參數(shù)。

    查看WP官網(wǎng) Codex get avatar 默認的可選參數(shù):

    <?php echo get_avatar( $id_or_email, $size, $default, $alt, $args ); ?>

    其中:$alt 就是 alt可選參數(shù)

    打開主題評論模板,找到類似這句:

    <?php echo get_avatar( $comment, 64 ); ?>

    替換為:

    <?php echo get_avatar( $comment, 64, '', get_comment_author() ); ?>

    將評論者名稱作為ALT屬性。

    如果你的主題調(diào)用評論模模塊使用的函數(shù)是:

    wp_list_comments();

    暫時在官網(wǎng)上還沒找到用該函數(shù)添加ALT屬性的參數(shù)(貌似WordPress默認主題ALT也是空的),只能按下面的代碼拆分這個函數(shù),然后修改。

    function mytheme_comment($comment, $args, $depth) {     if ( 'div' === $args['style'] ) {         $tag       = 'div';         $add_below = 'comment';     } else {         $tag       = 'li';         $add_below = 'div-comment';     }     ?>     <<?php echo $tag ?> <?php comment_class( emptyempty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">     <?php if ( 'div' != $args['style'] ) : ?>         <div id="div-comment-<?php comment_ID() ?>" class="comment-body">     <?php endif; ?>     <div class="comment-author vcard">         <?php if ( $args['avatar_size'] != 0 ) echo get_avatar( $comment, $args['avatar_size'] ); ?>         <?php printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>     </div>     <?php if ( $comment->comment_approved == '0' ) : ?>          <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em>           <br />     <?php endif; ?>     <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">         <?php         /* translators: 1: date, 2: time */         printf( __('%1$s at %2$s'), get_comment_date(),  get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), '  ', '' );         ?>     </div>     <?php comment_text(); ?>     <div class="reply">         <?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>     </div>     <?php if ( 'div' != $args['style'] ) : ?>     </div>     <?php endif; ?>     <?php     }

    如果你的主題添加修改了默認的頭像調(diào)用方式,比如使用CN或者SSl方式調(diào)用,該方法將無效。

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號