coffee2code.com/wp-plugins/author-images
Display image (if present) and/or name for the author of a post, or for all authors on the blog.
Use <?php c2c_the_author_image(); ?>
as a replacement for <?php the_author() ?>
in index.php (and other post templates) to display an image for a post’s author (inside “the loop”)
Use <?php c2c_wp_list_authors_images(); ?>
as a replacement for <?php wp_list_authors(); ?>
in the sidebar section of your site to list all authors for the blog using an image and/or text.
PROCESS BY WHICH IMAGE IS LOCATED OR TEXT USED INSTEAD:
- If a post has an ‘author_image’ custom field defined, the plugin checks if the value is the valid name of an image in $image_dir. If not, it appends each of the defined $image_extensions, in turn, to custom field’s value, then checks if an image can be found.
- If no image has been found yet, it looks under $image_dir for a file with a name that is the author’s ID with a file extension matching one of the ones defined in $image_extensions
NOTES:
– There are three configuration settings coded into the file:
* $show_name_AND_image
, which is defaulted to ‘true’. If set to ‘true’ then the author’s name will be displayed immediately following the image; if set to ‘false’, only the image (if found) will be displayed.
* $show_name_if_no_image
, which is defaulted to ‘true’. If set to ‘true’ and an image can’t be found, the author’s name will displayed as text; if set to 0 and an image can’t be found, then no information regarding the author is displayed.
* $link_type
, which is defaulted to ‘posts’ (other possible values are ‘site’ and ‘none) indicates what to link the author image/name to
– c2c_the_author_image()
is a drop-in replacement for WordPress’s the_author()
, allowing the author for the post to have an image displayed in lieu of the name (if an image can be found). If $image_extensions
is set to “”, then the function behaves just like the_author()
(assuming $show_name_if_no_image is also set to 1)
– Images output by c2c_the_author_image()
are defined with class="author_image"
for stylesheet manipulation
– If $image_extensions
is defined, but no image is found for the author, then nothing is displayed for that author.
– c2c_wp_list_authors_images()
is a drop-in replacement for WordPress’s wp_list_authors()
, allowing all authors for a blog to be listed with an image (if present)
– Images output by c2c_wp_list_authors_images()
are defined with class="list_author_image"
for stylesheet manipulation
– $image_extensions
can be defined as a space separated list of image extensions. Files will be checked with the image
extensions in the order those extensions were provided; default is ‘png gif jpg’.
TIPS:
– You can take advantage of the $image_extension
and/or $image_dir
arguments to display different author icons under different contexts, i.e. if showing a post on a permalink page, choose to use a ‘png’ image, otherwise use ‘gif’; or locate your images in different directories ‘/wp-content/images/authors/small/’ and ‘/wp-content/images/authors/large/’ and decide on context where to get the image(s) from.
CONFIGURATION OPTIONS:
The following configuration options are defined in the file; feel free to change them:
$show_name_AND_image = true; // Set this to 'true' to show author's name immeidately after author image; set to 'false' to only show the author image
$show_name_if_no_image = true; // Set this to 'true' to show author name if no author image is found; set to 'false' to refrain from showing anything if no author image is found
$link_type = 'posts'; // can be 'posts', 'site', or 'none'
// 'posts' links author image/name to a page of all of author's posts on this blog
// 'site' links author image/name to the author's home site, if specified in author's profile
// 'none' does not hyperlink the author's name
- Download the file author-images.zip and unzip it into your /wp-content/plugins/ directory.
-OR-
Copy and paste the the code ( author-images.phps ) into a file called author-images.php, and put that file into your /wp-content/plugins/ directory. Please ensure you do not introduce any spaces or other characters before the <?php or after the ?> - Optional: Change configuration options in the file to your liking. In-code comments should help you there.
- Activate the plugin from your WordPress admin ‘Plugins’ page.
- Create the directory(s) that will contain author image(s) (by default this would be /wp-content/images/authors/)
- Put images into the specified image directory, using the author ID as the filename, with whatever extension you plan to support, i.e. 1.gif
- Modify your index.php and/or other template files to include calls to
<?php c2c_the_author_images(); ?>
and/or<?php c2c_wp_list_authors_images(); ?>
. (Read the rest of these notes for more info.) - Optional: add the custom field ‘author_image’ to posts to explicitly define an image for the author for just that post. Otherwise, the plugin will proceed to attempt to find the author image.
- Optional: add the class “author_image” to your CSS file to control the dispaly of image produced by
c2c_the_author_image()
, and/or add the class “list_author_image” to your CSS file to control the display of the images listed byc2c_wp_list_authors_images()
function c2c_get_the_author_image ($idmode = '', $before = '', $after = '', $image_extensions = 'png gif jpg', $image_dir = '/wp-content/images/authors/')
- $idmode : (optional) id mode indicating the manner in which the author’s name is presented; default is ”, which displays user’s nickname
- $before : (optional) text or HTML to be displayed before the author image and/or name
- $after : (optional) text or HTML to be displayed after the author image and/or name
- $image_extensions : (optional) a space-separated list of image extensions to consider for use for the image(s) to be displayed, in the order they are to be considered; if defined as ” then no image is retrieved and the category name is displayed instead (a la the_category()); default is ‘png gif jpg’
- $image_dir : (optional) the directory in which to look for the image(s); default is ‘/wp-content/images/authors/”
For use in templates:
function c2c_the_author_image( $idmode = '', $echo = true )
- $idmode : optional; id mode indicating the manner in which the author’s name is presented; default is ”, which displays user’s nickname
- $echo : (optional) indicates if the author image and/or name should be displayed on the page; default is ‘true’
function c2c_wp_list_authors_images( $args = '' )
- $args : URL query string formatted arguments; valid option values are: optioncount, exclude_admin, show_fullname, hide_empty, feed, and feed_image
In your index.php, instead of having this default WordPress call for the author’s name:
<?php the_author(); ?>
Use this instead:
<?php c2c_the_author_image(); ?>
In your sidebar.php, if you would like to list all of your authors, try this:
<?php c2c_wp_list_authors_images(); ?>
- 27 Mar 2005 : v0.9 — Released to the public
Copyright (c) 2005 by Scott Reilly (aka coffee2code)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62 replies on “Plugin: Author Image(s)”
Thanks Michael, That what I’m looking for, I will try it out. God Bless to your work…..
[…] Author Images é um plugin que adiciona uma imagem ao perfil de um autor. O processo é um tanto manual. Depois de instalar o plugin, é necessário criar um diretório “/wp-content/images/authors/” e guardar lá as imagens de cada autor. […]
BRILLIANT…For some reason I could not get the authors avatars working from another plugin, but by changing the directory that your plugin looks for the avatars to the one generated by the other plugin, I’ve got it working just perfectly…
thanks so much for saving my sanity!
Kelly
Great Plugin. I am wondering how to incorporate an alt tag for the image? All images on your site needs an alt tag. Is this at all possible and if so, how?
This looks great, just what we are looking for! Do you have any idea if this also works with WordPress 2.0 and higher? Cheers!
garinungkadol.com/downloads/post-avatar/
Makes it easier for the one who prefers not modifying anything.
Still, thank you for creating this.
[…] Author Images: I was working with a client that ran a news blog. The blog had multiple authors, and my client wanted each author to get the proper credit for their work. This plugin does exactly that. […]
hey great job on the plugin.
this is a great plugin. i’ve been using it for a long time, but have recently been wondering if there is a way to show more than one author image per post. i often have multiple people working on one story for a site.
thanks a million for the plugin.
i’m using the plugin and i’m thinking i might be able to replace some of the author calls w/ coauthor ones. i’ll let you know if it works…
co-authors plugin, that is
2.5 told me that a new version of your plug-in was available, so I let it do the auto-upgrade and it installed a completely different plugin in place of author image. thought i’d give you a heads-up on that.
thanks again for the plugin. it’s great.