Post Avatar

A WordPress plugin simplifies the process of including a picture when writing posts. Authors simply choose from a predefined list of images in the Write Post page to display an image in a post. A template tag displays the image with The Loop. This plugin is similar to Livejournal userpics.

Authors: Vicky Arulsingam and Dominik Menke
Current Version: 1.5 (updated: May 11, 2012)
Download: post-avatar.zip
Get Support Here


Features
Installation
Usage
Translations
Donate
Version History (Changelog)
Known Issues

Post Avatar was a finalist at The 2007 Philippine Blog Awards for Best Plugin/Extension.

Features

  1. Easy selection of images in the Write Post screen.
  2. Scans images in sub-directories of the image option folder.
  3. Allows the following file types: .jpg, .jpeg, .gif and .png.
  4. Show avatar automatically in blog or use a template tag to display in themes.
  5. Does not display missing images.

Back to Top

Installation

  1. Upload the “post-avatar” directory to the WordPress plugin folder (/wp-content/plugins).
  2. Activate the plugin from the Plugin Management screen.
  3. Go to Settings » Post Avatar. Set the following options:

    * Path to Images Folder – location of your images folder in relation to your WordPress installation.

    * Scan the images directory and its sub-directories – Place a tick mark if you want to list all images including those in sub-directories of the image folder.

    * Show avatar in post – Show avatar automatically on your blog post. Uncheck to use the template tag (see Customizing Avatar Display, below).

Back to Top

Usage

A. UPLOAD IMAGES

Upload the images that you intend to use to the folder defined in the Post Avatar options.

B. ADDING AN AVATAR TO A POST

1. To add an image to a post, go to the Post Avatar section (just below the Save button).
2. Select the image name from the list.
3. Save your entry.

C. CUSTOMIZING AVATAR DISPLAY (Optional)

USING CSS
If you set the option “Show avatar in post”, images will automatically appear in your blog post. Customize the stylesheet inside “wp-content/plugins/post-avatar/head/” if necessary.

You can also set your own css class and html style inside the options page. These settings apply to the automatic avatar display and the default template tag in all templates where the_content() and the_excerpt() tags are used. To define a different HTML/CSS style in each template use the template tag options specified below.

USING THE TEMPLATE TAG “gkl_postavatar”
To customize the display of the avatar further, be sure to uncheck the option, “Show avatar in post”. You can use the template tag: gkl_postavatar.

Add the following within The Loop:

Default Code
<?php if (function_exists('gkl_postavatar')) gkl_postavatar(); ?>

By default, the plugin will show your image with the CSS class, “postavatar”. Customize gkl-postavatar.css inside the head folder.
For example:
<div class=”postavatar”><img src=”http://www.garinungkadol.com/wp-content/images/icons/messer01.jpg” alt=”title of post” style=”width:100px; height:100px; border:none;” /></div>

Define Own CSS Classes
You can also define your own CSS-classes by using a query string. By adding this to The Loop:
<?php if (function_exists('gkl_postavatar')) gkl_postavatar('example', '', ''); ?>

the result will be this:

<img class=”example” src=”http://www.garinungkadol.com/wp-content/images/icons/messer01.jpg” alt=”title of post” style=”width:100px; height:100px; border:none;” />

Define your own HTML
It is also possible to define your own HTML. Then you can use the string-parameters “before” and “after”:
If before = <p class=”mypic”> and after = </p> in this example:

<?php if (function_exists('gkl_postavatar')) gkl_postavatar('', '<p class="mypic">', '</p>'); ?>

will result in:

<p class=”mypic”><img src=”http://www.garinungkadol.com/wp-content/images/icons/messer01.jpg” alt=”title of post” style=”width:100px; height:100px; border:none;” /></p>

Image Without Styling
To show the image without any divs place this in The Loop:

<?php if (function_exists('gkl_postavatar')) gkl_postavatar('', '', ''); ?>

to get:

<img src=”http://www.garinungkadol.com/wp-content/images/icons/messer01.jpg” alt=”title of post” style=”width:100px; height:100px; border:none;” />

Back to Top

Translations

Thanks to all these people for translating Post Avatar

59 thoughts on “Post Avatar

  1. Hello, thank you for your plugins, good job!
    I have some thoughts,
    1 When user deactivate this plugin, it would be better that the plugin uninstall itself, including the variables in database table.
    2 When read/write variables from/into database, using addslashes/stripslashes can make the display correctly, especially the gklpa_before and gklpa_after variables.
    Thank you!

    • Hi rorocket,

      I’m planning on including a delete option when the user deactivates the plugin. That way they can choose to delete all the options when deactivating/uninstalling the plugin.

      Regarding request number 2, can you give me an example of HTML that isn’t being displayed properly?

      • Thank you for your reply!
        Last week, I transfer my wordpress data from one mysql to another, the gklpa_after variable are changed from to </div>, the same change with gklpa_before. Therefore, the page display strangely.
        I active and deactive Post Avatar many times, but it doesn’t work.
        I think it would be better to provide a button “Restore Factory Defaults”, it can change the decoded string back to the correct one.

  2. I’ve just installed your plugin on a new version of WP. I have it on an old version (2.4ish) and it works fabulously, I love it. I wanted to incorporate it on the new blog, but though I’ve added the icons folder and the path under Settings is correct, the dropdown to choose an avatar is empty. I’ve checked everything I know (which is not much, haha!) and don’t know what to try next. Any help is appreciated!

    • I fixed it! A silly oversight. Anyhow, thank you again for the plugin! I can now say it works fabulously on BOTH my blogs, haha… :)

  3. Thanks so much for this plugin.

    I was wondering if there was any way to have the image be displayed as the background to a table cell in html? I am having a hard time trying to figure this out.

    Thanks!!

    • I figured it out. I just want to thank you for writing the plugin so neatly.

      If anyone is wondering how to do it, I basically created the table within the plugin to assign the image as the background, and then closed the table outside the plugin. This allows the user to put dynamic text over the image. I’m not sure if this is proper practice… but it works.

      replace: ‘$post_avatar_text = $before .”. $after .”\n”;’

      with: ‘$post_avatar_text = $before .”.$after;’

      in index.php: text here

  4. Pingback: Post Avatar | CompareWordPressPlugins

  5. Fatal error: Maximum execution time of 20 seconds exceeded in /wp-content/plugins/post-avatar/gkl-postavatar.php on line 173
    …?

    • In that line of code the plugin is checking to see if the item in the directory you specified is a folder.
      Do you have a lot of images in that folder?
      If so, it’s because you’ve set the maximum execution time too low. You can increase it by adding this to your .htaccess
      php_value max_execution_time 200

  6. Pingback: 25 Useful Free WordPress Plugins For Multi-Author Blogs – Just a blog :)

  7. My code didn’t copy properly:
    if ( ! function_exists( ‘twentyeleven_posted_on’ ) ) :
    function twentyeleven_posted_on() {
    printf( __( ‘ %4$s by %7$s‘, ‘twentyeleven’ ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ),
    sprintf( esc_attr__( ‘View all posts by %s’, ‘twentyeleven’ ), get_the_author() ),
    esc_html( get_the_author() )
    );
    }
    endif;

  8. I’m having a hard time getting the avatar to appear next to the author’s name. I’ve added to functions.php (“pavatar” is what I named the div in the backend as well) but don’t know how to add the function. I tried adding the code you have in “usage” but I keep getting TSTRING errors.

    I’m trying to get it in to here:
    if ( ! function_exists( ‘twentyeleven_posted_on’ ) ) :
    function twentyeleven_posted_on() {
    printf( __( ‘ %4$s by

    %7$s‘, ‘twentyeleven’ ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    esc_attr( get_the_date( ‘c’ ) ),
    esc_html( get_the_date() ),
    esc_url( get_author_posts_url( get_the_author_meta( ‘ID’ ) ) ),
    sprintf( esc_attr__( ‘View all posts by %s’, ‘twentyeleven’ ), get_the_author() ),
    esc_html( get_the_author() )
    );
    }
    endif;

    Thanks so much!!

  9. Pingback: Powered By …

  10. Pingback: 7Maximes-News For Designers & Web Developers

  11. Pingback: Sacima鲨鳍马工作室 » Blog Archive » 25 Useful Free WordPress Plugins For Multi-Author Blogs

  12. Pingback: 25 Useful Free WordPress Plugins For Multi-Author Blogs

  13. How do you set it so the avatar will align with the subject/date? Right now I have it so the actual content of the post will align with the avatar. So using an example from below, it’s something like this at the moment:

    | Subject
    | Date
    | AVATAR text text text text text text text text text text text text text text text text text text text text text text text text text text text

    When I want:
    | AVATAR Subject
    | ” ” Date
    | ” ” text text text text text text text text text text text text text text text text text text text text text text text text text

    Is there somewhere I can set this within the plugin files, or is related to something else?

  14. Nice plugin. It was working fine for a long time until suddenly, the list of avatars is not showing when editing a post. I click on the dropdown list, and it’s blank. The settings and directories are all the same, I checked via FTP and the folder is still there, with all the images. Any idea what’s causing this and how to correct it? Thank you.

    • Ok, solved this. I had the full url in the “Path to Images Folder” blank, instead of just the path in relation to my installation. But what’s weird is, I don’t remember changing it, I think that was working before. Anyway, it’s working now. Thanks.

    • Ok, I see in the .css file where to change the position of the avatar (right or left), but I’m still curious if it’s possible to place it online with the post title? Thank you.

      • The automatic display option includes the post avatar image with the post content. So the most you can do is change your styling to move it around. If you want to place with the post title, you will have to disable the automatic display or use this code inside the “functions.php” file of your theme:
        remove_filter( 'the_content', 'gkl_postavatar_filter', 99 );

        Then inside your template files locate where you’ve placed “the_title” and include the post avatar like so:
        <?php gkl_postavatar('postavatar', ' ', ' '); ?><php the_title(); ?>

        Please see “Using the Template Tag ‘gkl_postavatar’” in Usage instructions.

  15. Hi,

    Is there a way to make the list of avatars selectable from each user profile ?
    And not only the author post page ?
    I want to let all users who comment to have their own avatars, not uploaded, but chosen from my list of pictures.

    I know that it might be different from the current function of the plug-in, but is it possible ?

    Thanks

    • The Post Avatar plugin is for posts/pages/custom post types only and isn’t easily ported to work with comments.

      You can try another plugin like: Custom Comment Fields

      I am currently working on a plugin for adding more comment fields but it’s still in the development stage.

      • At the moment I have this on my posts :

        | AVATAR
        |
        | text…text…text…text…text…text…text…text…text…text…

        And I want to have this :

        | AVATAR text…text…text…text…text…text…text…text…text
        | text…text…text…text…text…text…text…text…text
        | text…text…text…text…text…text…text…text…text…text…tex

        I want the first line of my post starts right of the avatar and dress the avatar, instead of starting under the avatar.

        It was possible on the last version, but I dont remember how to do.

        PS : I’m french, and my english is very poor ^^

        • Hmmmm. I think the problem has to do with the default stylesheet not being displayed. I’m going to look into this.

          • You need to go into your CSS file with FTP access.

            Folder Location should look something like this.

            …/wp-content/plugins/post-avatar/head/gkl-postavatar.css

            The CSS should be changed to this:

            .postavatar {
            float:left;
            marign-top: 0px;
            margin-left: 0px;
            margin-bottom: 15px;
            margin-right: 15px;
            }

            .postavatar img {
            float:left;
            marign-top: 0px;
            margin-left: 0px;
            margin-bottom: 15px;
            margin-right: 15px;

          • I just updated my version of WordPress and now the same thing is happening to me. I tried putting this in the settings ..
            but nothing is changed. I’d like the text to wrap around the avatar. Please assist!

  16. On some WP blogs
    “Go to Options » Post Avatar. Set the following options”
    is “Go to Settings » Post Avatar. Set the following options”

    • Thanks for the reminder. “Options” was the menu name in WP2.5 and below. I’ll change the description to reflect the correct path.

  17. Pingback: meloniq Technicznie » Spolszczenie Post Avatar

  18. Pingback: Veränderungen in der Pinguinpost « Relaxecke

  19. Pingback: Must-Have Plugins for Multi-Author WordPress Blogs | MYCOM SHOP

  20. Pingback: Top 10 Favourite WordPress Plugins by a Pregnant Chick — Superstructure

  21. Pingback: Top 10 Wordpresss Plugins | SEO Chicks

  22. Pingback: Wat is, en hoe wijzig ik de standaard avatar in Wordpress 2.5+

  23. Pingback: 10 Must-Have Plugins for Multi-Author WordPress Blogs | Best WordPress Plugins

  24. Pingback: TANEMM.COM » Wordpressカスタマイズの際使用したもの

  25. Pingback: agneson9 » Blog Archive » this is a client test

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>