Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPressで丸いGravatar画像を表示する方法

先日、コメントレイアウトと コメントフォームの スタイルをご紹介しました。あるユーザーからメールで「どうやってグラビア画像を丸くしたのですか?グラビア画像を丸くするためにローカルに保存しているのですか?” という質問がありました。この投稿では、WordPressで丸いgravatar画像を表示する方法を紹介します。CSS3のborder-radiusプロパティを使用して、円形のグラビア画像を作成します。

まず最初に、テーマのstyle.cssファイルを編集します。これはFTPプログラムを使うか、WordPress管理画面の外観 ” エディターから行うことができます。次に、CSSファイルに以下のコードを追加します:

[cbk1]

これはほとんどのWordPressテーマで動作するはずです。しかし、あなたのテーマでこれが機能しない場合、おそらくプラグインかテーマの機能がWordPressのgravatarに使用されているデフォルトのクラスをいじっている可能性があります。あなたのテーマでgravatar画像がどのCSSクラスを使っているかを調べるには、コメントをしているブログ投稿を開く必要があります。コメント欄までスクロールダウンし、gravatar画像を右クリックしてInspect Elementを選択します。このように、グラバターのソースコードが表示されます:

Finding css class used by gravatar icon

もしgravatar画像にavatar以外のものがあれば、上記のcssコードで.avatarの代わりにそれを使ってください。

この投稿がWordPressブログで丸いグラバター画像を表示するのにお役に立てば幸いです。ご質問やご意見がありましたら、下にコメントを残してください。

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

21件のコメント返信を残す

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Rex

    Very timely. Thank you so much.

    • WPBeginner Support

      You’re welcome :)

      管理者

  3. pujara

    How to add comment image automatically like in your comment system?

  4. Nataly

    hello, It worked, thank you, but, the description appear to high. over the pic, do you know to make it appear at the side of the pic?

  5. Therese

    I can’t make it work. :(
    I can’t figure out where exactly to put it, nothing seams to change. I’ve looked at the source code and it’s got avatar just like the example source code.

      • ERFmama

        Yes I did. I have the Twenty Twelve theme.
        Is there a specific place it has to go? In the style.css

        Edit: Never mind it suddenly worked now! :D

        Can I ask how to change the size of the avatars please? Or have you already written that down somewhere?

        Thank you so much for this!

  6. Daniel

    It worked, thank you

  7. Chrissy

    Fantastic! Exactly what I was looking for! Thanks you guys rock!

  8. Jacky

    THANK YOU so much for this, spent hours trying to accomplish. You provided the most straightforward solution!

  9. Abdul Samad

    Bro Thanks For This Code I’m New In WP and I really Enjoying Your Blog Man Thanks For THis And All Tutorials ….

  10. Richie

    I was going to pass along this tip and of course tried it first on one of my sites.

    Worked like a champ I simply changed my CSS from px to % for the border moz and webkit.

    Here’s where it got interesting.

    I went to another site, did the same tweak and it didn’t work. After a little head scratching I remembered that I had the plugin WP User Avatar installed on the site that it worked on and didn’t have it installed on the site it didn’t work on.

    I installed the plugin and whalah, works like a champ.

    For both sites I’m using a custom theme built on the Presswork framework.

    Bottom line, I got it to work but only with the plugin.

    Any ideas?

    • Editorial Staff

      It is possible that your theme wasn’t using the css class .avatar, and the plugin added that.

      管理者

      • Richie

        I’ll check it out. Thanks :)

  11. Roselle Celina

    Hi there, thanks for this tutorial! It’s working great on chrome and Firefox, but for Safari, I’m getting this same problem: http://jsfiddle.net/2UT8v/2/

    Thanks in advance for your help ;)

    • Editorial Staff

      It seems that the border width is where the issue seems to be in safari.

      管理者

  12. RW

    I agree and I only use IE about 4% of the time but several of my customers are still on 8.

    Thanks,
    Bob

  13. Martin

    If somebody uses IE8 does not deserve for round image ;)

  14. RW

    Great tip. Please note that IE8 doesn’t natively render round corners (border-radius). You’d need to use javascript, pie, etc… for this but not worth the trouble. Luckily IE9 recognizes current standards…

    Thanks.

    • Jim Burnett

      I remember the days we were trying to keep IE6 support in the loop. Not it’s IE 8 for rounded corners. Lucky us, IE9 is picking up.

      Then again, FF 3.0 doesn’t support any HTML 5. *sad face*

      Cool CSS trick though!

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。