Permalink
Browse files

'before' and 'after' arguments. Use get_the_ID() instead of the globa…

…l post object.

git-svn-id: http://svn.locallylost.com/themes/hybrid-core/trunk@921 dba0f204-706d-4bc1-bc29-8b92e0485636
  • Loading branch information...
1 parent 122289f commit 7a2fab2c1bd77e52ad600149909c67ab5ab40bae greenshady committed Nov 19, 2011
Showing with 24 additions and 23 deletions.
  1. +24 −23 extensions/get-the-image.php
@@ -47,30 +47,31 @@
* @return string|array The HTML for the image. | Image attributes in an array.
*/
function get_the_image( $args = array() ) {
- global $post;
/* Set the default arguments. */
$defaults = array(
- 'meta_key' => array( 'Thumbnail', 'thumbnail' ),
- 'post_id' => $post->ID,
- 'attachment' => true,
- 'the_post_thumbnail' => true, // WP 2.9+ image function
- 'size' => 'thumbnail',
- 'default_image' => false,
- 'order_of_image' => 1,
- 'link_to_post' => true,
- 'image_class' => false,
- 'image_scan' => false,
- 'width' => false,
- 'height' => false,
- 'format' => 'img',
- 'meta_key_save' => false,
- 'thumbnail_id_save' => false, // Set 'featured image'.
- 'callback' => null,
- 'cache' => true,
- 'echo' => true,
- 'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
- 'default_size' => null, // @deprecated 0.5. Use 'size'.
+ 'meta_key' => array( 'Thumbnail', 'thumbnail' ), // array|string
+ 'post_id' => get_the_ID(),
+ 'attachment' => true,
+ 'the_post_thumbnail' => true, // WP 2.9+ image function
+ 'size' => 'thumbnail',
+ 'default_image' => false,
+ 'order_of_image' => 1,
+ 'link_to_post' => true,
+ 'image_class' => false,
+ 'image_scan' => false,
+ 'width' => false,
+ 'height' => false,
+ 'format' => 'img',
+ 'meta_key_save' => false,
+ 'thumbnail_id_save' => false, // Set 'featured image'.
+ 'callback' => null,
+ 'cache' => true,
+ 'before' => '',
+ 'after' => '',
+ 'echo' => true,
+ 'custom_key' => null, // @deprecated 0.6. Use 'meta_key'.
+ 'default_size' => null, // @deprecated 0.5. Use 'size'.
);
/* Allow plugins/themes to filter the arguments. */
@@ -175,11 +176,11 @@ function get_the_image( $args = array() ) {
/* Or, if $echo is set to false, return the formatted image. */
elseif ( false === $echo ) {
- return $image;
+ return $args['before'] . $image . $args['after'];
}
/* Display the image if we get to this point. */
- echo $image;
+ return $args['before'] . $image . $args['after'];
}
/* Internal Functions */

0 comments on commit 7a2fab2

Please sign in to comment.