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.

Simple Image Grabber

Display one or all images from a post's content.

1) How can I customize the Simple Image Grabber function?

The images() function accepts five variables.

The basic use of the function looks like: <?php images( '1' ); ?> or <?php images(); ?>

This will display the first image from your post, with its default width and height, no class and a permalink to the post.

This is how the function looks with passing all variables directly or through an array:

<?php images( $number, $width, $height, $class, $permalink, $echo ); ?>
<?php 
$defaults = array(
    'number' => 1,
    'width' => null,
    'height' => null,
    'class' => 'alignleft',
    'permalink' => true,
    'echo' => true
);

images( $defaults ); 
?>

$number = the image you want to pull from your post, ie. the first image from the post ('1') or the second image from the post ('2') and so on. NOTE: If you use 'all', it will display all images from the post.

$width = the width of the displayed image

$height = the height of the displayed image

$class = the class you would like to assign to the displayed image

$permalink = whether you would like the image to link to the post or not

$echo = echo or return the value

The following function will echo the second image from a post (if there is one) with a width of 150px and a height of 200px, the class "alignleft" and no link to the post.

<?php images( '2', '150', '200', 'alignleft', false ); ?>

The following will return all images from a post with their original width and height, a class name of alignright and a link to the post.

<?php 
$args = array(
    'number' => 'all',
    'class' => 'alignright',
    'echo' => 0
);

$all_images = images( $args );
?>

Requires: 2.7 or higher
Compatible up to: 3.4.2
Last Updated: 2012-6-4
Downloads: 11,744

Ratings

4 stars
4.4 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,2,2
100,1,1
100,1,1
100,1,1
100,1,1