Tôi đang sử dụng plugin WordPress này để tải lên nhiều hình ảnh.http://wordpress.org/plugins/upload-multiple-image/ Nó cho tôi một chức năng trả về một mảng 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 )
1.Nhưng tiếp theo tôi không biết làm thế nào để hiển thị mảng này?
Tôi muốn hiển thị tất cả các hình ảnh trong định dạng này. Những gì tôi nên làm để có được đường dẫn hình ảnh trong 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 )
2, 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 )
3, 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, 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 )
5.<img src="<?php echo $img1; ?>" alt="">
<img src="<?php echo $img2; ?>" alt="">
<img src="<?php echo $img3; ?>" alt="">
<img src="<?php echo $img4; ?>" alt="">
Nếu tôi làm điều này 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 )
6, nó sẽ trả lại điều nàyArray ( [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 )
Đã hỏi ngày 14 tháng 5 năm 2014 lúc 6:40May 14, 2014 at 6:40 Ý tưởng BigTechBigTechBigtech Ideas 871 Huy hiệu vàng4 Huy hiệu bạc14 Huy hiệu đồng1 gold badge4 silver badges14
bronze badges 4 Nhanh chóng và dễ dàng: // Get images as array
$images = get_multiple_image($post_id);
// Loop over images and echo
foreach($images as $img) {
echo '<img src="'.$img.'" alt="">';
}
Hoặc nếu bạn muốn đặt một văn bản hình ảnh thay thế có nguồn gốc từ chỉ mục vòng lặp: // Loop over images and echo
for($i = 0; $i < count($images); $i++) {
echo '<img src="'.$images[$i].'" alt="Image #'.($i+1).'">';
}
Đã trả lời ngày 14 tháng 5 năm 2014 lúc 11:07May 14, 2014 at 11:07 try $images = get_multiple_image($post_id);
foreach($images as $img) {?>
<img src="<?php echo $img; ?>" alt="">
<?php }?>
hoặc cho đường dẫn bạn có thể sử dụng các giá trị chỉ mục mảng $img1 = $images[0];
$img2 = $images[1];
và như thế.... Đã trả lời ngày 14 tháng 5 năm 2014 lúc 6:45May 14, 2014 at 6:45 Rakesh Sharmarakesh SharmaRakesh Sharma 13.7K4 Huy hiệu vàng36 Huy hiệu bạc44 Huy hiệu đồng4 gold badges36 silver badges44 bronze badges
Thử cái này $AllImages = get_multiple_image($post_id);
foreach($AllImages as $image)
{
echo "<img src='".$image."' alt=''>";
}
Đã trả lời ngày 14 tháng 5 năm 2014 lúc 6:47May 14, 2014 at 6:47 Vishal Sharmavishal SharmaVishal Sharma 1.3721 Huy hiệu vàng8 Huy hiệu bạc17 Huy hiệu đồng1 gold badge8 silver badges17
bronze badges <?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=''>";
}
Đầu ra sẽ là, 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
và kết quả <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=''>
Xem ví dụ Đã trả lời ngày 14 tháng 5 năm 2014 lúc 6:58May 14, 2014 at 6:58 Sử dụng mã này. 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 )
0 |