简体   繁体   中英

Pull all images from a URL folder and display in Boostrap HTML

I need to pull all images from a URL directory (they are not displayed...just sitting in a folder on a server that I do not have access to) and display them within a Bootstrap Image gallery. http://www.electrictoolbox.com/extract-images-web-page-php/

<?php
require_once('./simple_html_dom.php');
require_once('./url_to_absolute.php');
$url = 'http://www.bbc.co.uk';
$html = file_get_html($url);
foreach($html->find('img') as $element) {
echo url_to_absolute($url, $element->src), "\n";
}
?>

The URL for the folder where all the images are stored is: http://masterplan.imgix.net/Slimming_Book/

Is it possible for php to scan this URL directory and pull the images to another website that is being hosted on another server?

Bit late but I figured I'd answer this. The below PHP code loads all ".png" images from the directory and then echos the image tag. You would replace the plain html tag for the equivalent bootstrap one.

dirname = "media/images/cats/";
$images = glob($dirname."*.png");
foreach($images as $image) {
echo '<img src="'.$image.'" /><br />';
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM