WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WP Get Post Image

Adds the function wp_get_post_image(), giving theme builders easy access to images associated with a post or page.

This plugin provides the template tag wp_get_post_image(). Use it to call dynamically created images uploaded via the WordPress media uploader.

NOTE: This plugin is intended for use by WordPress developers and theme builders only.

Usage

<?php wp_get_post_image($args); ?>

Default Usage

<?php $args = array(
    'width' => null,
    'height' => null,
    'css' => '',
    'parent_id' => '',
    'post_id' => '',
    'filename' => '',
    'return_html' => true       
); ?>

By default, the function returns:

  • The last uploaded image wrapped in an image tag (<img />).
  • A proportionately sized image with a width no greater than 200px.
  • The CSS class wp-image-*ID* and no other classes.
  • If you add thickbox via css, the appropriate anchor <a> tag will be added for Thickbox compatibility.

Parameters

  • width (integer) - Width of image.

  • height (integer) - Height of image.

  • parent_id (integer) - The ID of the post_parent for the attachment. Specifying the parent_id returns the first image attached to the parent post according to menu_order.

  • post_id (integer) - The ID of the attachment.

  • filename (string) - The filename that corresponds to the post_name of the attachment.

  • return_html (boolean) - true returns the image wrapped in an XHTML image tag. false returns the image's URL.

Example

<?php 
// use this example wherever you have access to $post->ID, e.g. the WordPress loop
if(function_exists('wp_get_post_image'))
    echo wp_get_post_image('width=450&css=alignleft&parent_id='.$post->ID);  
?>

Requires: 2.8.4 or higher
Compatible up to: 3.0.5
Last Updated: 2010-1-27
Downloads: 8,780

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
100,1,1
100,1,1
100,1,1
100,1,1
0,1,0
0,2,0
100,1,1