1

I am using this wordpress plugin to upload multiple images. http://wordpress.org/plugins/upload-multiple-image/

It gives me a function that return an array get_multiple_image($post_id). But next I don't know how to display this array?

I want to display all images in this format.

What I should do to get images path in $img1, $img2, $img3, $img4.

<img src="<?php echo $img1; ?>" alt="">
<img src="<?php echo $img2; ?>" alt="">
<img src="<?php echo $img3; ?>" alt="">
<img src="<?php echo $img4; ?>" alt="">

if I do this print_r(get_multiple_image($post_id)); it return this

Array ( [0] => http://localhost/arabian/wp-content/uploads/2014/05/flaconi-bag1.png [1] => http://localhost/arabian/wp-content/uploads/2014/05/hoods-products1.png [2] => http://localhost/arabian/wp-content/uploads/2014/05/product-ring1.png [3] => http://localhost/arabian/wp-content/uploads/2014/05/soud-gloves1.png )
4
  • print_r(get_multiple_image($post_id)) and show your output Commented May 14, 2014 at 6:41
  • If you want to output the img-tags you can use a foreach loop Commented May 14, 2014 at 6:43
  • what is the array format? paste a sample array Commented May 14, 2014 at 6:45
  • Thanks rakesh sharma... now I get an array see in question. How can i save this array in $img1, $img2, ....... Commented May 14, 2014 at 6:45

5 Answers 5

1

Quick and easy:

// Get images as array
$images = get_multiple_image($post_id);

// Loop over images and echo
foreach($images as $img) {
    echo '<img src="'.$img.'" alt="">';
}

Or if you want to set an alternative image text derived from the loop index:

// Loop over images and echo
for($i = 0; $i < count($images); $i++) {
    echo '<img src="'.$images[$i].'" alt="Image #'.($i+1).'">';
}
Sign up to request clarification or add additional context in comments.

Comments

1

try

$images = get_multiple_image($post_id);
foreach($images as $img) {?>
<img src="<?php echo $img; ?>" alt="">
<?php }?>

or for path you can use array index values

$img1 = $images[0];
$img2 = $images[1];

and so on....

Comments

0

Try this

$AllImages = get_multiple_image($post_id);

foreach($AllImages as $image)
{
  echo "<img src='".$image."' alt=''>";
} 

Comments

0
<?php
$images=array('http://localhost/arabian/wp-content/uploads/2014/05/flaconi-bag1.png','http://localhost/arabian/wp-content/uploads/2014/05/hoods-products1.png','http://localhost/arabian/wp-content/uploads/2014/05/product-ring1.png','http://localhost/arabian/wp-content/uploads/2014/05/soud-gloves1.png');

print_r($images);
foreach($images as $key){
echo "<img src='".$key."' alt=''>";
}

The output will be,

Array
(
    [0] => http://localhost/arabian/wp-content/uploads/2014/05/flaconi-bag1.png
    [1] => http://localhost/arabian/wp-content/uploads/2014/05/hoods-products1.png
    [2] => http://localhost/arabian/wp-content/uploads/2014/05/product-ring1.png
    [3] => http://localhost/arabian/wp-content/uploads/2014/05/soud-gloves1.png
) // your array

and the result

<img src='http://localhost/arabian/wp-content/uploads/2014/05/flaconi-bag1.png' alt=''>
<img src='http://localhost/arabian/wp-content/uploads/2014/05/hoods-products1.png' alt=''>
<img src='http://localhost/arabian/wp-content/uploads/2014/05/product-ring1.png' alt=''>
<img src='http://localhost/arabian/wp-content/uploads/2014/05/soud-gloves1.png' alt=''>

See example

Comments

0

Use this code.

$post_id = get_the_ID();
$MultiImages = get_multiple_image($post_id);

foreach($MultiImages as $img)
{
  echo "<img src='".$img."' alt=''>";
} 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.