Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17

Thread: display images in a folder

  1. #16
    Join Date
    May 2013
    Quote Originally Posted by Henry07 View Post
    this is a php code
    $files = glob("images/*.*");
    for ($i=0; $i<count($files); $i++)
    $num = $files[$i];
    echo '<img src="'.$num.'" alt="random image" />'."<br><br>";

    Duplichecker - Plagiarism software

  2. #17
    Join Date
    Mar 2007
    All you need to get thumb nails is to use the getimagesize() function in conjunction with list() to obtain the height and width of the image then use a calculation to ensure that the resizing of height and width is not going to result in an image that is out of proportion.

    I used something like this for my images

    PHP Code:
    $ext = array("jpg","png","gif","bmp");
    $ext as $typ){
    $dir glob("*.{$typ}");
    $img array_combine$dir $img);

    $ratio 0.33// approx 1/3rd

    foreach($img as $thumb){
    $width$height$type$attr) = getimagesize$thumb );
    $height $height $ratio;
    $width $width $ratio;
    "<img height='{$height}' width='{$width}' title='' src='{$thumb}'; /><br>\r\n";    

    its been a long time since I looked at the script but thats the basics of what I did.
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center