=== Author Image(s) === Contributors: coffee2code Donate link: http://coffee2code.com/donate Tags: author, authors, image, avatar, icon, post, list, coffee2code Requires at least: 2.8 Tested up to: 3.0.1 Stable tag: 3.0 Version: 3.0 Display image (if present) and/or name for the author of a post, or for all authors on the blog. == Description == Display image (if present) and/or name for the author of a post, or for all authors on the blog. Use as a replacement for in index.php (and other post templates) to display an image for a post's author (inside "the loop") Use as a replacement for 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: 1. 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. 1. 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. 1. 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. 1. 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 Tip:: You can take advantage of the $image_dir argument to display different author images under different contexts, i.e. 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. == Installation == 1. Unzip `author-images.zip` inside the `/wp-content/plugins/` directory (or install via the built-in WordPress plugin installer) 1. Activate the plugin through the 'Plugins' admin menu in WordPress 1. Go to the Settings -> Author Images admin options page. Optionally customize the options. 1. Create the directory(s) that will contain author image(s) (by default this would be /wp-content/images/authors/) 1. 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 1. Modify your index.php and/or other template files to include calls to `` and/or ``. (Read the rest of these notes for more info.) 1. (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. 1. (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()`. == Screenshots == 1. A screenshot of the plugin's admin options page. == Frequently Asked Questions == = Where do I go to upload the author images? = Currently this plugin does not facilitate the uploading of images. It assumes you've already managed to get the author images onto your server into the appropriate directories. = Does this have a widget? = Not yet. == Template Tags == The plugin provides two optional template tags for use in your theme templates. = Functions = * `function c2c_the_author_image( $before = '', $after = '', $image_dir = '', $width = '', $height = '' )` 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). This displays the image associated with a post's categories. = Arguments = * `$before` Optional argument. The text and/or HTML to appear before the author image/text, if any such text would be returned. * `$after` Optional argument. The text and/or HTML to appear after the author image/text, if any such text would be returned. * `$image_dir` Optional argument. 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. * `$width` Optional argument. The forced width of the image (will cause browser to resize if image is of different width). Leave blank to retain image's original width (or for the width to be scaled in proportion to a specified height). It is recommended that images exist at the desired size. * `$height` Optional argument. The forced height of the image (will cause browser to resize if image is of different height). Leave blank to retain image's original height (or for the height to be scaled in proportion to a specified width). It is recommended that images exist at the desired size. * `$args` Optional argument. 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? == Examples == * Show the author image for the current post's author (must be "in the loop") `` * Get the author image from a different directory when on a post's permalink page (for instance, show a larger image on the permalink page) `` * List all authors in the sidebar `` * Change some default options when listing authors `` == Filters == The plugin exposes three actions for hooking. = c2c_get_the_author_image (filter) = The 'c2c_get_the_author_image' hook allows you to use an alternative approach to safely invoke `c2c_get_the_author_image()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site. Arguments: * same as for c2c_get_the_author_image() Example: Instead of: `` Do: `` = c2c_the_author_image (action) = The 'c2c_the_author_image' hook allows you to use an alternative approach to safely invoke `c2c_the_author_image()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site. Arguments: * same as for c2c_the_author_image() Example: Instead of: `', '', '/images' ); ?>` Do: `', '', '/images' ); ?>` = c2c_wp_list_authors_images (action) = The 'c2c_wp_list_authors_images' hook allows you to use an alternative approach to safely invoke `c2c_wp_list_authors_images()` in such a way that if the plugin were deactivated or deleted, then your calls to the function won't cause errors in your site. Arguments: * same as for c2c_wp_list_authors_images() Example: Instead of: ` false ) ); ?>` Do: ` false ) ); ?>` == Changelog == = 3.0 = * Re-implementation by extending C2C_Plugin_012, which among other things adds support for: * Reset of options to default values * Better sanitization of input values * Offload of core/basic functionality to generic plugin framework * Additional hooks for various stages/places of plugin operation * Easier localization support * Add setting 'height' to allow for forced browser-scaling of the height of the author image (better if the original image is of desired size) * Add setting 'width' to allow for forced browser-scaling of the width of the author image (better if the original image is of desired size) * Add setting 'custom_field' to allow easier configuration of the post custom field for defining a specific author image to use for the post (default is 'author_image') * For get_the_author_image(), c2c_get_the_author_image(), and c2c_the_author_image(), add optional $width and $height arguments to force image width/height * Add filters 'c2c_get_the_author_image', 'c2c_the_author_image', and 'c2c_wp_list_authors_images' to respond to the function of the same name so that users can use the do_action('c2c_the_author_image') notation for invoking template tags * For c2c_wp_list_authors_images(), add support in $args for 'feed_type', 'style', and 'html' * Rename class from 'AuthorImages' to 'c2c_AuthorImages' * Rename the global instance variable from 'author_images' to 'c2c_author_images' * Trim leading and trailing forward slashes from the custom field value before use * Change to make leading and trailing forward slashes optional for $image_dir value * Wrap each global function in function_exists() check * Use get_options() instead of get_settings() * Remove docs from top of plugin file (all that and more are in readme.txt) * Note compatibility with WP 2.8+, 2.9+, 3.0+ * Drop compatibility with versions of WP older than 2.8 * Minor tweaks to code formatting (spacing) * Add Changelog and Upgrade Notice sections to readme.txt * Add PHPDoc documentation * Add package info to top of file * Update copyright date * Remove trailing whitespace * Add screenshot * Adding to WP plugin repository == Upgrade Notice == = 3.0 = Recommended update. Highlights: re-implementation; added more settings and hooks for customization; misc improvements; verified WP 3.0 compatibility; dropped compatibility with WP older than 2.8; added to WP plugin repository.