coffee2code

Author Image(s)

Author:Scott Reilly
Version:2.0
Last update:15 April 2008
Compatibility:WP 2.2+, 2.3+ and 2.5+
Comments:go here
Download:[ zip ]
Description:
Display image (if present) and/or name for the author of a post, or for all authors on the blog.

Extended Description

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 the image is located and/or text used:

If a post has an ‘author_image’ custom field defined, the plugin checks if the value is the valid name of an image in the defined image directory. If not, it appends each of the defined image extensions, in turn, to the custom field’s value, then checks if an image can be found. If no image has been found yet, it looks in the image directory for a file with a name that is the author’s login name with a file extension matching one of the ones defined in image extensions. If no image has been found yet, it looks in the image directory 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. If an image has been found and the “Show author name as well?” setting is true, or if no author image has been found and “Show author name if image is found?” setting is true, then the author’s name is appended/used.

Additional notes:

The plugins admin options page allows you to control if the author’s name should appear alongside the author image or not, if the author name should be shown in the event no author image could be found, the image directory, the support image extensions, and if and what you want the author image to link to. Images output by c2c_the_author_image() are defined with class=”author_image” for stylesheet manipulation Images output by c2c_wp_list_authors_images() are defined with class=”list_author_image” for stylesheet manipulation

Screenshot

A screenshot of the post’s admin options page.

screenshot 1


Installation

Download the file author-images.zip and unzip it into your wp-content/plugins/ directory. Activate the plugin through the ‘Plugins’ admin menu in WordPress. Go to the Options → Author Images (or in WP 2.5: Setings → Author Images) admin options page. Optionally customize the options. 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 login name or the author ID as the filename, with whatever extension you plan to support, i.e. admin.gif or 1.gif Modify your index.php and/or other template files to include calls to <?php c2c_the_author_image(); ?> and/or <?php c2c_wp_list_authors_images(); ?>. (Read documentation 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 display of the image located 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 by c2c_wp_list_authors_images().

Template Tags

There are two template functions made available by this plugins.

Functions

function c2c_the_author_image( $before = '', $after = '', $image_dir = '' )

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).

function c2c_wp_list_authors_images( $args = '' )
A drop-in replacement for WordPress’s wp_list_authors(), allowing all authors for a blog to be listed with an image (if present).

Arguments:

$before
Optional. The text and/or HTML to appear before the author image/text, if any such text would be returned..
Default value: ''
$after
Optional. The text and/or HTML to appear after the author image/text, if any such text would be returned.
Default value: ''
$image_dir
Optional. The directory, relative to the root of your blog, in which to find the author images. If not set, it defaults to the value configured via the plugin’s admin options page.
Default value: ''
$args
Optional. An array of configuration options. All but the last two match up with the supported arguments of the wp_list_authors() function.
optioncount : default of false; exclude_admin : default of true; should the admin user be excluded from the listing? show_fullname : default of false; should the user’s first and last name be shown? hide_empty : default of true; should authors who have not made any posts be excluded from the listings? feed : default of '' feed_image : default of '' echo : default of true; should the listing be echoed to the page? show_name : default of '' which means it’ll abide by the plugin’s setting value; should the name of the author be shown in addition to the image? show_name_if_no_image : default of '' which means it’ll abide by the plugin’s setting value; should the author’s name be shown if the author doesn’t have an image?

Frequently Asked Questions

Q: Where do I go to upload the author images?

A: Currently this plugin does not facilitate the uploading of images. It assumes you’ve already managed to get the author images onto your server.


Release Log


Copyright & Disclaimer

Copyright © 2005-2008 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.


Acknowledgements

Thanks to all those who have contributed feedback and support!


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser